Azure providers and identity
Three providers, three responsibilities
AzureRM is the usual Terraform provider for Azure infrastructure. AzAPI exposes Azure Resource Manager resource types and API versions more directly when the typed AzureRM schema does not expose a feature. AzureAD retains its historical package name while targeting Microsoft Entra directory objects through Microsoft Graph. A virtual network, a new ARM API property and an application registration are therefore different tasks, even if they belong to the same project. Avoid managing the same property or resource through multiple writers.
Imagine a catalog service: AzureRM owns its network, AzureAD may own the application registration, and AzAPI may cover a specifically justified ARM gap. The provider selection depends on the exact feature, permissions and lifecycle, not on how many providers a project can install.
Pin the provider and declare the target
A provider source identifies the plugin package; a provider configuration selects how it connects. The following example retains the track’s provisional CLI pin and uses an illustrative AzureRM 4.74.0 pin supported by indexed version-specific documentation. It has not been installed, security-reviewed or executed. The repeated-digit IDs are fictional. The required features block enables the provider’s feature configuration; its empty form accepts provider defaults, which should be reviewed before a real run.
# Static example; do not initialize or authenticate.terraform { required_version = "= 1.14.8" required_providers { azurerm = { source = "hashicorp/azurerm" version = "= 4.74.0" } }}provider "azurerm" { features {} tenant_id = "11111111-1111-1111-1111-111111111111" subscription_id = "22222222-2222-2222-2222-222222222222" resource_provider_registrations = "none"}The tenant is the directory context for authentication; the subscription is the target scope for most ARM resources. AzureRM 4.x requires a subscription ID for plan/apply, which can also be supplied through supported environment configuration. Neither ID is an authorization token. An explicit target helps avoid accidental subscription selection but does not grant access.
Authentication is different from authorization
A human in an approved disposable lab may use an existing authorized interactive identity. For automation, prefer an identity designed for the workload, such as a managed identity when the execution host supports it, or federated short-lived tokens when the issuer and identity trust are configured. A service principal represents an application in a tenant; managed identity is an Azure-managed form of workload identity. A role assignment determines permitted ARM actions and scope. Graph permissions for directory operations and data-plane permissions for services are separate concerns. Never embed a client secret, token or private key in HCL, variables, plans or a worksheet.
# Alternative provider configuration, not an additional default block.# Variables and an approved federated identity are prerequisites.provider "azurerm" { features {} tenant_id = var.tenant_id subscription_id = var.subscription_id client_id = var.client_id use_oidc = true resource_provider_registrations = "none"}This fragment demonstrates one alternative, not a second default provider. It assumes declared variables, an approved OIDC token source, matching issuer/subject/audience trust, and scoped roles. It does not configure trust or log in. A valid token with the wrong audience or insufficient role cannot authorize a resource operation.
Registration can change the subscription
An Azure resource provider is an ARM service namespace, such as Microsoft.Network. This is not the same thing as a Terraform plugin. Registration enables a subscription to use a service namespace; it is not permission to manage every resource in that namespace. AzureRM can attempt registrations during provider configuration in plan/apply, depending on version and settings. The explicit none setting in this example avoids the configured automatic registration set; do not add resource_providers_to_register if registration must remain external. The subscription owner should confirm the necessary namespaces are registered separately. This does not make a real plan offline or read-only: it can still authenticate and read remote objects. Never fix registration errors by granting broad administrator roles indiscriminately.
Choose the correct interface before planning
Use the following decision record for a hypothetical team, not as executable configuration.
Task Interface to investigateCreate a standard VNet AzureRMUnsupported ARM property AzAPI (check API version and ownership)Create an Entra application AzureAD (Graph permissions)Authorize storage data read Service data-plane role and identityRecord the exact package/version, tenant, subscription, resource owner, credential mechanism and minimum role scope. Confirm how plan behaves for that version. A provider binary is executable code; only use approved artifacts and a verified dependency lock in an isolated environment. Next, inspect the target resource structure and scope.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Azure providers and identity — knowledge check
Review Azure provider selection, scope and identity.
Which provider normally owns a standard Azure virtual network?
Which service does AzureAD primarily use for directory objects?
What does a subscription ID establish?
Why use configured workload federation in CI?
What does setting resource_provider_registrations to none establish in the shown configuration?