Introduction
Microsoft Azure provides national clouds, such as US Government and China, which are physically isolated instances of Azure. These environments ensure that data residency, sovereignty, and compliance requirements are honored within specific geographical boundaries.
This guide explains how to configure the Terraform Azure provider to authenticate and deploy resources to these national clouds.
Procedure
Follow these steps to configure your environment for an Azure national cloud.
-
Set the Azure CLI cloud environment.
You must configure the Azure CLI to target the desired national cloud. Run one of the following commands.
For the US Government cloud:
$ az cloud set --name AzureUSGovernment
For the China cloud:
$ az cloud set --name AzureChinaCloud
-
Log in to the Azure CLI.
After setting the cloud environment, authenticate your session.
$ az login
-
Configure the Azure provider in Terraform.
In your Terraform configuration, update the
azurermprovider block to specify the national cloud environment. Theskip_provider_registrationargument is required to prevent the auto-registration of resource providers, which may not be available or may behave differently in these environments.provider "azurerm" { ## For China cloud, use "china". ## For US Government cloud, use "usgovernment". environment = "china" skip_provider_registration = true features {} } -
Deploy your Terraform configuration.
Run
terraform planandterraform applyto test the deployment of your resources to the selected national cloud.