Introducing a new way to review your PRs.

Read the announcement

prowler-cloud / prowler

This repo hosts Prowler OSS (CLI and Local Server). Prowler is the world’s most widely used open-source cloud security platform that automates security and compliance across any cloud environment for Humans and AI Agents.

View on GitHub

13 documents · Updated Nov 16, 2026

docs / azure-provider

Azure Provider

Overview

The Azure provider is rooted at prowler/…/azure_provider.py. AzureProvider.__init__ validates the selected authentication mode, builds an AzureRegionConfig, creates the Azure credential/session object, discovers identity/subscription metadata, lists available locations, validates optional resource group scope, then loads audit config and AzureMutelist before registering itself as the global provider. The CLI-facing arguments live in prowler/…/arguments.py: one of --az-cli-auth, --sp-env-auth, --browser-auth, or --managed-identity-auth is selected, --subscription-id/--subscription-ids optionally narrows subscriptions, --azure-region selects AzureCloud, AzureChinaCloud, or AzureUSGovernment, and --azure-resource-group(s) narrows resource enumeration.

Authentication in prowler/…/azure_provider.py has four paths. Static tenant/client/secret arguments are prevalidated with UUID/secret checks and a direct token request in verify_client, then wrapped in ClientSecretCredential. Non-browser CLI, service-principal-env, and managed identity modes use DefaultAzureCredential with every unselected credential source explicitly excluded; service-principal-env also requires AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET. Browser mode uses InteractiveBrowserCredential and requires tenant_id. setup_region_config pulls per-cloud authority, ARM base URL, ARM credential scope, Graph host/scope, and Log Analytics endpoint from prowler/…/regions.py, so sovereign cloud behavior is centralized in that model.

Identity and scan scope are discovered in AzureProvider.setup_identity. For service principals, browser auth, Azure CLI, or static client IDs, it tries Microsoft Graph (GraphServiceClient) for the default tenant domain and user identity where possible, then uses SubscriptionClient with the selected cloud base URL/scope to list all subscriptions or resolve the subscription IDs provided by the user. Subscriptions are stored as {subscription_id: display_name} to avoid display-name collisions, tenant IDs come from subscriptions_client.tenants.list(), and no subscriptions is a critical setup failure. get_locations records Azure locations per subscription. validate_resource_groups uses ResourceManagementClient per subscription to case-insensitively resolve requested resource groups into {subscription_id: [real_rg_names]}; if no group filter is configured, services scan whole subscriptions.

Azure services share prowler/…/service.py. AzureService.__init__ builds per-subscription clients, copies provider subscriptions, region config, resource group scope, locations, audit config, and fixer config, and provides list_with_rg_scope() so resource services can switch between list_all and list_by_resource_group. Normal ARM SDK clients are instantiated once per subscription with credential, subscription_id, base_url, and credential_scopes. GraphServiceClient is special: __set_clients__ builds a GraphRequestAdapter with AzureIdentityAuthenticationProvider scoped to region_config.graph_scope and an HTTP client hosted at region_config.graph_host. LogsQueryClient is also special because it is per subscription but receives endpoint=region_config.logs_endpoint rather than a subscription ID.

Each concrete service under prowler/providers/azure/services/<service>/ follows the same scan pattern. A <service>_service.py subclasses AzureService, gathers Azure resources at construction time, and maps Azure SDK objects into local Pydantic models or dataclasses; a <service>_client.py creates a singleton from Provider.get_global_provider(); each check imports that singleton and iterates its cached resources to build Check_Report_Azure findings. For example, prowler/…/storage_service.py gathers storage accounts with list_with_rg_scope, enriches each account with blob and file-service properties, and exposes storage_accounts keyed by subscription; storage_secure_transfer_required_is_enabled.py emits one finding per account and sets report.subscription to the subscription ID while using the display name for human text. prowler/…/vm_service.py uses the same pattern for VMs, disks, and VM scale sets; prowler/…/network_service.py applies it to NSGs, public IPs, VNets, WAF policies, and gateways; prowler/…/monitor_service.py collects subscription diagnostic settings and activity log alert rules.

Directory shape is the routing signal for future reviewers: provider/session changes are in prowler/…/azure_provider.py, shared service-client behavior is in prowler/…/service.py, region endpoint behavior is in prowler/…/regions.py, check-specific logic is in prowler/…/<check>.py, and the resource inventory feeding those checks is in prowler/…/<service>_service.py. The permissions/azure/** cover glob currently has no files in this checkout, so Azure permissions guidance is not represented by a covered source file here.

Tests mirror that layout under tests/providers/azure/. tests/…/azure_provider_test.py covers authentication argument failures, test_connection, static credential validation, sovereign cloud authorities/endpoints, subscription-client base URLs, provider-id validation, resource group validation, and the asyncio.run() identity path. tests/…/azure_fixtures.py provides set_mocked_azure_provider() plus subscription/domain constants for service and check tests. Service tests patch Azure SDK calls or service collectors and assert the local models, while check tests patch the module-level singleton client before importing/executing the check, as shown by tests/…/storage_service_test.py and tests/…/storage_secure_transfer_required_is_enabled_test.py.

Coupling

  • If prowler/…/regions.py adds or changes a cloud endpoint, update AzureRegionConfig in prowler/…/models.py, the credential/session construction in prowler/…/azure_provider.py, and AzureService.__set_clients__ in prowler/…/service.py; tests in tests/…/azure_provider_test.py, tests/…/regions_test.py, and tests/…/azure_service_test.py assert ARM, Graph, and Log Analytics endpoints separately.
  • If subscription identity shape changes in AzureProvider.setup_identity, update services and mutelist logic that assume subscriptions are keyed by subscription ID: service loops in files such as prowler/…/storage_service.py, check reports such as storage_secure_transfer_required_is_enabled.py, and AzureMutelist.is_finding_muted in prowler/…/mutelist.py.
  • If resource group filtering changes, verify every service that calls Azure list APIs uses AzureService.list_with_rg_scope() with the correct all-subscription and per-resource-group methods. Storage, VM, network, AI Search, and AI Services already do this in their service files; services that list tenant-level Graph objects or subscription-level monitor/log resources should not blindly adopt resource-group filtering.
  • If a service model field is renamed or its default changes in a <service>_service.py, update all checks that read that field and their tests. The check modules do not call Azure directly; they rely on the local model contract populated by the service singleton.
  • If Entra user retrieval changes in prowler/…/entra_service.py, keep the error maps (sign_in_activity_errors, users_retrieval_errors) aligned with user-based checks: permission/licensing failures should not turn into empty inventories that checks treat as compliant/non-compliant evidence.

Risks

  • prowler/…/service.py and prowler/…/azure_provider.py are fragile around sovereign clouds. History shows repeated fixes for endpoint drift (fix(azure): pass authority to credentials for sovereign clouds, fix(azure): use the selected cloud endpoints in Defender and Key Vault), and a missed base_url, Graph host, scope, or Log Analytics endpoint sends scans to public-cloud APIs even when --azure-region selects China or US Government.
  • prowler/…/azure_provider.py stores subscriptions by ID to avoid display-name collisions. A prior fix addressed scanning every subscription when display names collide; reverting to display-name keys would silently drop one of two same-named subscriptions and reduce scan coverage.
  • prowler/…/entra_service.py has explicit fallback paths for Microsoft Graph pagination, sign-in activity 403s, and transient user retrieval failures. If those paths are simplified, checks can mistake missing Graph permissions, Entra ID licensing, throttling, or a failed later page for a real empty user inventory and produce false PASS/FAIL results.
  • Resource group scoping spans AzureProvider.validate_resource_groups, AzureService.list_with_rg_scope, and many service collectors. The history includes a follow-up fix after resource group scoped scans; changing only the provider-side map or only individual service list methods can either skip valid scoped resources or fall back to full-subscription scans without making that visible in findings.