How to use Azure.Identity with Azure Government Cloud, Azure German Cloud, and Azure China Cloud

Azure has many cloud instances like: Azure Public, Azure Government, Azure German, and Azure China. You can see the full cloud list and associated endpoints via the Azure CLI command az cloud list.

If you try to use the new Azure Identity library with one of those clouds, you will get this error:

AADSTS900382: Confidential Client is not supported in Cross Cloud request

That is because all of the libraries default to using as the Azure Active Diretory authority host. Each of the other clouds have different authority host endpoints, as you can see from the Azure Government profile here:

The activeDirectory property doesn’t end with .com it ends with .us, and every cloud is different.

    "endpoints": {
      "activeDirectory": "",
      "activeDirectoryDataLakeResourceId": null,
      "activeDirectoryGraphResourceId": "",
      "activeDirectoryResourceId": "",
      "batchResourceId": "",
      "gallery": "",
      "management": "",
      "mediaResourceId": "",
      "microsoftGraphResourceId": "",
      "ossrdbmsResourceId": "",
      "resourceManager": "",
      "sqlManagement": "",
      "vmImageAliasDoc": ""
    "isActive": true,
    "name": "AzureUSGovernment",
    "profile": "latest",
    "suffixes": {
      "acrLoginServerEndpoint": "",
      "azureDatalakeAnalyticsCatalogAndJobEndpoint": null,
      "azureDatalakeStoreFileSystemEndpoint": null,
      "keyvaultDns": "",
      "sqlServerHostname": "",
      "storageEndpoint": ""

When you instantiate Azure.Identity.DefaultAzureCredential() without any parameters:

const credential = new DefaultAzureCredential();

You will get the following error:

AADSTS900382: Confidential Client is not supported in Cross Cloud request

What you need to do is instantiate DefaultAzureCredential with the proper authority host for the cloud you are targeting. Run az cloud list to find the appropriate activeDirectory endpoint.

You can set via the AZURE_AUTHORITY_HOST environment variable or use the AzureAuthorityHosts enums.

Here’s what you need to do for each language:

Setting Authority Host via the AZURE_AUTHORITY_HOST Environment Variable

As of the following releases, each Azure SDK library now supports setting authority host via the AZURE_AUTHORITY_HOST environment variable.

.NET: Azure.Identity 1.2.0

Python: azure-identity 1.4.0

Java: 1.1.0

JavaScript/TypeScript: @azure/identity 1.1.0

Setting Authority Host via the “AuthorityHost” property and AzureAuthorityHosts enums.


var options = new DefaultAzureCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzureGovernment };
var client = new KeyClient(new Uri(keyVaultUrl), new DefaultAzureCredential(options));

With service version number:

var client = new KeyClient(new Uri(keyVaultUrl), new DefaultAzureCredential(options), new KeyClientOptions(KeyClientOptions.ServiceVersion.V7_0));


DefaultAzureCredential cred = new DefaultAzureCredentialBuilder()

KeyClient keyClient = new KeyClientBuilder()

With service version number:

KeyClient keyClient = new KeyClientBuilder()


credential = DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
client = KeyClient(vault_url=VAULT_URL, credential=credential)

With service version number:

client = KeyClient(vault_url=VAULT_URL, credential=credential, api_version="7.0")


const credential = new DefaultAzureCredential({ authorityHost: KnownAuthorityHosts.AzureGovernment });
const client = new KeyClient(url, credential);

With service version number:

const client = new KeyClient(url, credential, { serviceVersion: "7.0" });

Service Version Error

If you get the following error, then you’ll need to explicitly set the version number. Both examples are shown above for each language.

The specified version (7.1) is not recognized. Consider using the latest supported version (2016-10-01).