Recommended way to store Terraform state in Azure?

Sachdeva, Sonika 40 Reputation points
2026-07-16T16:55:57.1633333+00:00

Hello,
I'm using Terraform to manage Azure Policy resources across multiple tenants. My plan is to store state in an Azure Storage Account (azurerm backend), using one storage account with a separate state file per tenant.

Questions:

  1. Is Azure Storage Account still the recommended backend for Terraform state in Azure, or is there a newer preferred option?
  2. Is one storage account with a separate state file per tenant a good practice, or should each tenant get its own storage account?
  3. Does the azurerm backend handle state locking automatically, or does it need extra setup?
  4. What is currently recommended for securing the storage account

Tags: Terraform, Azure Storage, Infrastructure as Code

Azure Storage
Azure Storage

Globally unique resources that provide access to data management services and serve as the parent namespace for the services.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-07-16T16:56:33.4433333+00:00
    1. Azure Storage is the documented approach for storing remote Terraform state in Azure. The guidance describes creating an Azure storage account, using Azure Storage to store remote Terraform state, and using the azurerm backend.
    2. The documented guidance confirms Azure Storage as the backend, but it does not prescribe a tenant-isolation pattern such as one storage account per tenant versus one shared storage account with separate state files per tenant. What is supported is:
      • the backend uses a storage account,
      • a blob container,
      • and a key value, which is the name of the state file.
      That means separate state files per tenant are supported by using different key values. The guidance also notes these security considerations:
      • Terraform state is stored in plain text and may contain secrets.
      • In production, use the most secure authentication option supported by the azurerm backend for the use case.
      • In production, restrict storage account access by using a storage firewall, service endpoint, or private endpoint.
    3. State locking is automatic. Azure Storage blobs are automatically locked before any operation that writes state. This prevents concurrent state operations that can cause corruption. No extra setup for locking is described.
    4. Current security recommendations from the guidance are:
      • Do not write the storage access key to disk; use an environment variable for access_key.
      • Prefer retrieving the access key with Azure CLI or Azure PowerShell.
      • For stronger protection, store the storage account access key in Azure Key Vault and set the environment variable from Key Vault.
      • Evaluate the available authentication options supported by the azurerm backend and use the most secure option for the scenario.
      • Restrict network access to the storage account with a storage firewall, service endpoint, or private endpoint.
      • Be aware that Terraform state is plain text and may contain secrets, so incorrect security can lead to unauthorized access and data loss.
      • Azure Storage encrypts blob data at rest.

    A supported backend configuration requires these values:

    • storage_account_name
    • container_name
    • key
    • access_key

    Typical flow:

    1. Create the Azure Storage account and blob container.
    2. Retrieve the storage account key and set ARM_ACCESS_KEY as an environment variable.
    3. Configure the Terraform backend block.
    4. Run terraform init.
    5. Run terraform apply.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.