Introduction
This article will walk you through troubleshooting steps when you receive a 404 response while publishing an image in the Azure China Cloud.
Problem
Encountering the following error while executing a Packer build for a Windows VM in Azure China — despite providing the correct Tenant ID, Subscription ID, and other authentication details:
Build 'azure-arm.windows' errored after 2 seconds 48 milliseconds: clientCredentialsToken: received HTTP status 400 with response: {"error":"invalid_request","error_description":"AADSTS90002:
Tenant not found.
Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant
"error_uri":"https://login.microsoftonline.com/error?code=90002"}
Cause
Microsoft operates three Clouds — Azure Public, Azure Government, and Azure China. These are physically isolated Azure instances specifically designed to meet stringent requirements for data residency, sovereignty, and regulatory compliance within their respective geographic boundaries.
The error above typically indicates a configuration issue related to Azure China authentication. Most commonly, this error occurs when the request is directed to the public Azure cloud endpoints, rather than the Azure China endpoints.
Solutions:
Ensure that Packer is explicitly configured to use the Azure China environment by setting the correct environment value in the azure-arm
builder config:
cloud_environment_name = "China"
cloud_environment_name
(string) - One of Public, China, or USGovernment. Defaults to Public. Long forms such as USGovernmentCloud and AzureUSGovernmentCloud are also supported.
Additional Information
- Azure China cloud
- Azure ARM builder
- If you're still experiencing issues, please contact HCP Terraform Support by submitting a ticket through our support portal