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 SDK 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 SDKs 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.

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

You will notice that some languages allow you to use a KnownAuthority enum while others require that you enter the full URL. I have filed issues with each of the other languages to support KnownAuthorities as well:


// Version 1.2.0-preview.1 or greater
var options = new DefaultAzureCredentialOptions { AuthorityHost = KnownAuthorityHosts.AzureUSGovernment };

// Versions prior to 1.2.0-preview.1
// var options = new DefaultAzureCredentialOptions { AuthorityHost =  new Uri("") };
var client = new KeyClient(new Uri(keyVaultUrl), new DefaultAzureCredential(options));


Option 1 (Version 1.1.0-beta.2 +)

NOTE: The DefaultAzureCredentialBuilder().authorityHost method was introduced in azure-identityversion 1.1.0-beta.2. Please include the following in your pom.xml file



// Version 1.1.0-beta.2 or greater
DefaultAzureCredential cred = new DefaultAzureCredentialBuilder()

KeyClient keyClient = new KeyClientBuilder().vaultUrl(dotenv.get("AZURE_KEYVAULT_URL")).credential(cred)

Prior to version 1.1.0-beta.2 it was not possible to set the DefefaultAzureCredential.authorityHost. You have two options if you cannot use v1.1.0-beta.2

Option 2

Only needed if you can’t use 1.1.0-beta.2+

Use reflection to set the underlying identityClientOptions property:

IdentityClientOptions options = new IdentityClientOptions().setAuthorityHost("");
DefaultAzureCredentialBuilder cred = new DefaultAzureCredentialBuilder();
Field identityClientOptions = cred.getClass().getSuperclass().getDeclaredField("identityClientOptions");
identityClientOptions.set(cred, options);

KeyClient keyClient = new KeyClientBuilder().vaultUrl(dotenv.get("AZURE_KEYVAULT_URL"))

Option 3

Only needed if you can’t use reflection and can’t use 1.1.0-beta.2+

Use the EnvironmentCredentialBuilder class instead of DefaultAzureCredentialBuilder:

KeyClient keyClient = new KeyClientBuilder().vaultUrl(dotenv.get("AZURE_KEYVAULT_URL"))
  .credential(new EnvironmentCredentialBuilder().authorityHost("").build()).buildClient();


credential = DefaultAzureCredential(authority=KnownAuthorities.AZURE_GOVERNMENT)


const credential = new DefaultAzureCredential({ authorityHost: "" });