When deploying with Terraform to Azure you may sometimes encounter errors such as this:
╷
│ Error: creating Automation Account (Subscription: "83fa140a-2bea-175a-395c-914cae2902ce"
│ Resource Group Name: "production"
│ Automation Account Name: "backup-automation"): automationaccount.AutomationAccountClient#CreateOrUpdate: Failure responding to request: StatusCode=409 -- Or
iginal Error: autorest/azure: Service returned an error. Status=409 Code="MissingSubscriptionRegistration" Message="The subscription is not registered to use
namespace 'Microsoft.Automation'. See https://aka.ms/rps-not-found for how to register subscriptions." Details=[{"code":"MissingSubscriptionRegistration","mes
sage":"The subscription is not registered to use namespace 'Microsoft.Automation'. See https://aka.ms/rps-not-found for how to register subscriptions.","targe
t":"Microsoft.Automation"}]
The problem is that in Azure you may need to register the provider for the service you intend to manage with Terraform. If you add resources from Azure Portal this registration part is handled automation. In the above case the Azure Automation provider was missing.
To figure out which provider you need to register either go to Microsoft documentation here, or use az cli to find the correct one:
az provider list --output table
Then register the provider (here for Azure Automation):
az provider register --namespace Microsoft.Automation
It takes a while before the provider is registered, so you can monitor registration state with a command such as this:
az provider show -n Microsoft.Automation