How to fix Error: Cannot register providers in Terraform
Terraform automatically attempts to register Azure resource providers when initializing the AzureRM provider. This error occurs when your Azure account lacks sufficient permissions to register providers, typically due to restricted subscription-level access or IAM policy constraints.
Quick fix
Fixes Error: Cannot register providers
provider "azurerm" {
features {}
skip_provider_registration = true
}- Add skip_provider_registration = true to your provider block
- Manually register required providers using Azure CLI
- Verify Azure credentials and permissions
- Request permissions from subscription administrator
provider "azurerm" {features {}skip_provider_registration = true}Error: Cannot register providers
What this error means
When you use Terraform with the Azure provider, it automatically tries to register all supported resource providers (like Microsoft.Compute, Microsoft.Storage, etc.) on your Azure subscription to enable better error messages and resource provisioning. This registration action requires 'Microsoft.*/register/action' permissions at the subscription scope. If your account is restricted to resource group level or lacks these permissions, this error appears.
Typical symptoms
- Terraform apply fails with 'Cannot register providers: Microsoft.X' message
- Error includes 'AuthorizationFailed' or 'Context deadline exceeded'
- Terraform works in local testing but fails in CI/CD pipelines
- Error occurs during terraform init or plan phase
- Only affects newly created Azure subscriptions or accounts with limited permissions
Common causes
- Azure account has insufficient permissions at the subscription level (e.g., restricted to resource group scope only)
- Service principal or managed identity lacks Microsoft.*/register/action permission
- Azure subscription is newly created and providers haven't been cached yet
- Context timeout when registering multiple providers simultaneously
- Network or Azure API latency causing timeout during provider registration
How to fix "Error: Cannot register providers"
For AzureRM provider versions 3.x and earlier, add the skip_provider_registration flag to disable automatic provider registration:
provider "azurerm" {
features {}
skip_provider_registration = true
}For AzureRM provider version 4.x and later, use:
provider "azurerm" {
features {}
resource_provider_registrations = "none"
}This prevents Terraform from attempting to register providers automatically.
If you prefer to keep automatic registration enabled, manually register the providers that your Terraform code uses with a privileged account:
# Register a specific provider
az provider register -n Microsoft.Compute --wait
# Or register multiple providers
az provider register -n Microsoft.Compute --wait
az provider register -n Microsoft.Storage --wait
az provider register -n Microsoft.Network --waitUse az provider list to see all registered and pending providers.
Ensure your Azure authentication is correctly configured and your account has the necessary permissions:
# Check current Azure CLI authentication
az account show
# List subscriptions to verify access
az account list
# Check role assignment for provider registration
az role assignment list --scope /subscriptions/{subscriptionId}Confirm that your account has 'Owner' or 'Contributor' role at the subscription level, or has a custom role with Microsoft.Authorization/roleAssignments/write and Microsoft.*/register/action permissions.
If you don't have sufficient permissions, contact your Azure subscription administrator to either:
1. Grant your service principal or user account the 'Contributor' role at the subscription level
2. Manually register all required providers before running Terraform
3. Create a custom IAM role that grants Microsoft.*/register/action permission
Once permissions are granted, retry terraform plan and apply.
Ensure you're using the latest versions of both tools:
# Update Azure CLI
az upgrade
# Check Azure CLI version
az --version
# Update Terraform AzureRM provider in your configuration
terraform init -upgradeNewer versions often include bug fixes and improved error handling for provider registration issues.
Advanced notes
By default, Terraform registers all providers it supports, not just those you use in your configuration. This provides better error messages but requires subscription-level permissions. If you disable automatic registration and later use a resource from an unregistered provider, the error message may be misleading (e.g., 'API version not found' instead of 'provider not registered'). This is particularly important in managed environments like Azure DevOps or GitHub Actions where service principals have restricted permissions. For CI/CD pipelines, it's often simpler to either use skip_provider_registration or pre-register providers in your infrastructure setup phase. Be aware that some Azure features (like certain API versions) may only work with newer provider registrations, so check Azure release notes if you encounter unexpected API compatibility issues.
Frequently asked questions
- What does "Error: Cannot register providers" mean?
- ) on your Azure subscription to enable better error messages and resource provisioning. */register/action' permissions at the subscription scope. If your account is restricted to resource group level or lacks these permissions, this error appears.
- How do I fix "Error: Cannot register providers"?
- Terraform automatically attempts to register Azure resource providers when initializing the AzureRM provider. This error occurs when your Azure account lacks sufficient permissions to register providers, typically due to restricted subscription-level access or IAM policy constraints.
- What causes "Error: Cannot register providers"?
- Azure account has insufficient permissions at the subscription level (e.g., restricted to resource group scope only) Service principal or managed identity lacks Microsoft.*/register/action permission Azure subscription is newly created and providers haven't been cached yet
- Is the "Error: Cannot register providers" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐Terraform Official Documentation
- ๐