This error occurs when the Terraform Azure provider attempts to use an API version that doesn't exist or isn't registered in your subscription. It typically indicates either resource provider registration issues, API version mismatch, or regional API support limitations.
The Terraform AzureRM provider uses specific API versions to interact with Azure resources. When you see 'API version 2019-XX-XX was not found for Microsoft.Foo', it means either the Resource Provider 'Microsoft.Foo' requires registration, the region doesn't support that API version, or you're using an API version that's incompatible with your resource type. The Azure API versioning system is complex because different resource types support different API versions, and newer API versions may offer additional functionality like DataActions that older versions don't support.
If you don't have permission to register Resource Providers, use the skip_provider_registration flag in your Terraform provider block:
provider "azurerm" {
skip_provider_registration = true
features {}
}Alternatively, use the newer resource_provider_registrations option set to "none" to disable auto-registration.
Use a recent version of the AzureRM provider in your terraform block. Older versions don't know about newer API versions:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.0"
}
}
}Run terraform init to update the provider, then check your provider's version history for API version updates.
The error typically includes a list of supported API versions for your region. For example, if the error says 'supported api-versions are 2021-06-01-preview', change your resource to use that version. Some resources don't expose API versions directly in Terraform, so this may require provider updates or using the AzAPI provider instead.
The user, service principal, or managed identity running Terraform must have permission to register Resource Providers. If you see a 403 AuthorizationFailed error with 'does not have authorization to perform action Microsoft.X/register/action', you need to either:
- Request elevated permissions (Contributor or higher role)
- Use skip_provider_registration = true if another admin has pre-registered the providers
If you need to use a specific API version or access the latest Azure features not yet available in AzureRM, switch to the AzAPI provider. It's a thin layer on top of the Azure REST APIs and allows you to specify any API version:
provider "azapi" {
features {}
}
resource "azapi_resource" "example" {
name = "myResource"
type = "Microsoft.Foo/bars@2024-01-01"
location = "eastus"
}You can use AzAPI alongside AzureRM. The aztfmigrate tool helps migrate resources between the two providers.
API version selection varies by resource type. The AzureRM provider uses specific API versions for each resource, and these are updated in provider releases. The challenge is that API versions aren't always well-documented—it can be difficult to find what API version Terraform is using for a given resource. Use the AzAPI VS Code extension for visibility into all available resource types and their API versions. Preview API versions (ending in '-preview') may require enabling them in your subscription first. For role assignments specifically, older API versions (2015-07-01) don't support DataActions, so you may need to upgrade if working with custom roles.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform