When using useFederatedToken: true in Azure Government, Loki ignores the AZURE_AUTHORITY_HOST env var injected by the Azure Workload Identity webhook. Auth requests
hit login.microsoftonline.com instead of login.microsoftonline.us, resulting in AADSTS900382: Confidential Client is not supported in Cross Cloud request.
The root cause is in pkg/storage/chunk/client/azure/blob_storage_client.go lines 518-544, where the AD endpoint is resolved via azure.EnvironmentFromName() from the
config field rather than from AZURE_AUTHORITY_HOST. Loki already reads AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_FEDERATED_TOKEN_FILE from env vars but misses
AZURE_AUTHORITY_HOST.
To Reproduce
- Deploy Loki on Azure Kubernetes Service in an Azure Government subscription
- Enable Azure Workload Identity (webhook injects
AZURE_AUTHORITY_HOST=https://login.microsoftonline.us/)
- Configure Loki with
useFederatedToken: true and Azure Blob storage backend without explicitly setting environment: AzureUSGovernment
- Observe auth failure:
AADSTS900382: Confidential Client is not supported in Cross Cloud request
Expected behavior
Loki should respect AZURE_AUTHORITY_HOST when constructing the federated token credential, consistent with how the Azure Workload Identity webhook communicates the
correct authority endpoint to workloads.
Proposed fix
- Check
AZURE_AUTHORITY_HOST before falling back to azure.EnvironmentFromName(), or
- Migrate from deprecated
go-autorest/adal to azidentity which respects AZURE_AUTHORITY_HOST natively
Workaround
Set environment: AzureUSGovernment under loki.storage.azure in Helm values.
Environment:
- Infrastructure: Kubernetes (AKS, Azure Government)
- Deployment tool: Helm
Relevant code
https://github.com/grafana/loki/blob/main/pkg/storage/chunk/client/azure/blob_storage_client.go#L518-L544
When using
useFederatedToken: truein Azure Government, Loki ignores theAZURE_AUTHORITY_HOSTenv var injected by the Azure Workload Identity webhook. Auth requestshit
login.microsoftonline.cominstead oflogin.microsoftonline.us, resulting inAADSTS900382: Confidential Client is not supported in Cross Cloud request.The root cause is in
pkg/storage/chunk/client/azure/blob_storage_client.golines 518-544, where the AD endpoint is resolved viaazure.EnvironmentFromName()from theconfig field rather than from
AZURE_AUTHORITY_HOST. Loki already readsAZURE_CLIENT_ID,AZURE_TENANT_ID, andAZURE_FEDERATED_TOKEN_FILEfrom env vars but missesAZURE_AUTHORITY_HOST.To Reproduce
AZURE_AUTHORITY_HOST=https://login.microsoftonline.us/)useFederatedToken: trueand Azure Blob storage backend without explicitly settingenvironment: AzureUSGovernmentAADSTS900382: Confidential Client is not supported in Cross Cloud requestExpected behavior
Loki should respect
AZURE_AUTHORITY_HOSTwhen constructing the federated token credential, consistent with how the Azure Workload Identity webhook communicates thecorrect authority endpoint to workloads.
Proposed fix
AZURE_AUTHORITY_HOSTbefore falling back toazure.EnvironmentFromName(), orgo-autorest/adaltoazidentitywhich respectsAZURE_AUTHORITY_HOSTnativelyWorkaround
Set
environment: AzureUSGovernmentunderloki.storage.azurein Helm values.Environment:
Relevant code
https://github.com/grafana/loki/blob/main/pkg/storage/chunk/client/azure/blob_storage_client.go#L518-L544