How to fix API version was not found for Microsoft in Terraform
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.
Quick fix
Fixes API version was not found for Microsoft
provider "azurerm" {
skip_provider_registration = true
features {}
}- Disable automatic provider registration
- Update your Terraform Azure provider version
- Use the suggested API version from the error message
- Ensure proper subscription permissions
provider "azurerm" {skip_provider_registration = truefeatures {}}API version was not found for Microsoft
What this error means
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.
Typical symptoms
- Terraform plan or apply fails with 'API version X was not found for Microsoft.Y'
- Error message suggests supported API versions: 'The supported api-versions are 2021-06-01-preview'
- Region-specific errors: 'No registered resource provider found for location westus2'
- Permission-related errors when Terraform tries to auto-register providers
- Role assignment operations fail with DataActions incompatibility errors
Common causes
- Resource Provider not registered in your subscription (most common)
- Using an API version not supported in your Azure region
- Terraform provider version is too old and doesn't know about newer API versions
- Insufficient permissions to register Resource Providers (403 AuthorizationFailed)
- Using an older API version that doesn't support required features like DataActions
- Attempting to use preview API versions without enabling them in your subscription
How to fix "API version was not found for Microsoft"
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.
Advanced notes
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.
Frequently asked questions
- What does "API version was not found for Microsoft" mean?
- The Terraform AzureRM provider uses specific API versions to interact with Azure resources. 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.
- How do I fix "API version was not found for Microsoft"?
- 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.
- What causes "API version was not found for Microsoft"?
- Resource Provider not registered in your subscription (most common) Using an API version not supported in your Azure region Terraform provider version is too old and doesn't know about newer API versions
- Is the "API version was not found for Microsoft" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.