How to fix: Error ensuring Resource Providers are registered When Connecting Terraform to Azure

Published by

on

Time to read:

1–2 minutes

In this post, we are going to go over a quick solution when you are running into the ‘Error ensuring Resource Providers are registered’ while using Terraform to automate your Microsoft Azure infrastructure.


  1. SECTION I – Terraform
    1. FIGURE 1 – Terraform
  2. SECTION II – The Error
    1. FIGURE 2 – Terraform Fails to Connect to Azure
  3. SECTION III – The Solution
    1. Example 1 – Terraform Azure Provider Configuration

SECTION I – Terraform

Terraform is an infrastructure automation software that allows you to utilise the concept of Infrastructure as Code (IaC). The main advantages of using Terraform are:

  1. Multi-platform – works on Linux, MAC and Windows.
  2. Previews – allows preview of infrastructure changes before they are implemented.
  3. Parallelisation – allows parallelisation of operations.
  4. Integrations – integrates large number of providers/applications. – https://registry.terraform.io/browse/providers

IaC is the process of writing the code for the provisioning and configuration steps of the infrastructure components to help automate its deployment in a repeatable and consistent manner.

The benefits of IaC are:

  • Standardisation of infrastructure configuration – less risk of errors.
  • Version controlled code stored in a source code manager.
  • code integrated into Continuous Integration/Continuous Development pipelines.
  • Faster and more efficient infrastructure changes.
  • Better management and control of infrastructure with reduced costs.

Terraform is a declarative type of IaC meaning that in the code you put what you want the final state of the infrastructure to be and Terraform will get the current state of the infrastructure and then make any changes required to make it equal the desired state.

FIGURE 1 – Terraform

SECTION II – The Error

When trying to run your ‘terraform plan’ or ‘terraform apply’ commands you get the following error as Terraform tries to connect to MS Azure:

Error: Error ensuring Resource Providers are registered.
FIGURE 2 – Terraform Fails to Connect to Azure

SECTION III – The Solution

A quick solution to this error that you can try is add the following line to your providers declaration portion of your code:

skip_provider_registration = "true"

With it added your Azure provider configuration will look similar to that in Example 1.

provider "azurerm" {
    features {}
    subscription_id = "<subscription_id>"
    client_id = "<client_id>"
    client_secret = "<client_secret>"
    tenant_id = "<tenant_id>"
    skip_provider_registration = "true"
}
Example 1 – Terraform Azure Provider Configuration

Leave a comment