Error: unable to get authorization token for resource manager: MSI not available

Hello,

We are using terraform to deploy resources in azurerm. But have been facing this error very intermittently which started for a couple of days which comes even when we run terraform plan.


│ Error: unable to get authorization token for resource manager: MSI not available

│ with provider[“registry.terraform.io/hashicorp/azurerm”],
│ on main.tf line 19, in provider “azurerm”:
│ 19: provider “azurerm” {

Below is the version that we are using in the code

required_providers {
aviatrix = {
source = “aviatrixsystems/aviatrix”
version = “~> 2.0”
}
azurerm = {
source = “hashicorp/azurerm”
version = “>= 2.72.0”
}
}
}
provider “aviatrix” {}
provider “azurerm” {
features {}
use_msi = true
}

We enabled debug and below are the logs for the same.

2021-08-16T12:20:52.947Z [INFO] provider.terraform-provider-azurerm_v2.72.0_x5: Using Managed Service Identity for Authentication: timestamp=2021-08-16T12:20:52.947Z

2021-08-16T12:20:52.947Z [DEBUG] provider.terraform-provider-azurerm_v2.72.0_x5: Using MSI msiEndpoint http://169.254.169.254/metadata/identity/oauth2/token: timestamp=2021-08-16T12:20:52.947Z

2021-08-16T12:20:52.947Z [INFO] provider.terraform-provider-azurerm_v2.72.0_x5: Getting OAuth config for endpoint https://login.microsoftonline.com/ with tenant df722068-5fa4-4ebb-9e7f-1aa5ffa6b96f: timestamp=2021-08-16T12:20:52.947Z

2021-08-16T12:20:52.947Z [DEBUG] provider.terraform-provider-azurerm_v2.72.0_x5: getAuthorizationToken with MSI msiEndpoint http://169.254.169.254/metadata/identity/oauth2/token, ClientID “” for msiEndpoint https://management.azure.com/: timestamp=2021-08-16T12:20:52.947Z

2021-08-16T12:20:53.076Z [INFO] provider.terraform-provider-aviatrix_v2.19.5: 2021/08/16 12:20:53 [INFO] Aviatrix Client configured for use: timestamp=2021-08-16T12:20:53.076Z

│ Error: unable to get authorization token for resource manager: MSI not available

│ with provider[“registry.terraform.io/hashicorp/azurerm”],

│ on main.tf line 19, in provider “azurerm”:

│ 19: provider “azurerm” {