How do you configure the Terraform azurerm provider and backend?
BeginnerConceptAzure DevOps, Bicep and Terraform
Answer
terraform {
required_providers {
azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" }
}
backend "azurerm" {
resource_group_name = "rg-tfstate"
storage_account_name = "sttfstateshop"
container_name = "tfstate"
key = "shop/prod.tfstate"
use_azuread_auth = true
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id # required in azurerm v4 (or ARM_SUBSCRIPTION_ID)
}
The features {} block is mandatory. use_azuread_auth = true uses Entra RBAC (Storage Blob Data Contributor) instead of storage keys. State locking uses blob leases.
More on Azure DevOps, Bicep and Terraform
What services make up Azure DevOps?BeginnerWhat are branch policies in Azure Repos?BeginnerExplain the YAML pipeline structure in Azure Pipelines.BeginnerWhat are service connections and how should they authenticate?IntermediateWhat are environments in Azure Pipelines?IntermediateWhat deployment strategies do deployment jobs support?Intermediate