Report #14747
[bug\_fix] InvalidAuthenticationTokenAudience
Request the access token using the correct resource/audience URI for the specific Azure service being accessed. When using Azure Identity SDK, specify the correct \`authority\` or \`scope\`. For Key Vault, request a token for \`https://vault.azure.net\`. For Azure Storage, use \`https://storage.azure.com\`. For ARM, use \`https://management.azure.com\`. Ensure the token acquisition request uses the resource-specific scope \(e.g., \`https://vault.azure.net/.default\`\) rather than a token obtained for a different resource.
Journey Context:
A DevOps engineer writes a Terraform configuration that uses the Azure provider to create resources and also uses the \`azurerm\_key\_vault\_secret\` data source to fetch secrets. The authentication uses a Service Principal via environment variables \(\`ARM\_CLIENT\_ID\`, \`ARM\_CLIENT\_SECRET\`, \`ARM\_TENANT\_ID\`\). The Terraform plan succeeds for resource creation but fails when accessing Key Vault with 'InvalidAuthenticationTokenAudience'. The engineer decodes the JWT access token using jwt.ms and notices the 'aud' claim is 'https://management.azure.com/'. However, Key Vault requires an audience of 'https://vault.azure.net/'. The engineer realizes that the Azure Terraform provider automatically requests tokens for the management endpoint \(ARM\), and when the same credential is used to call the Key Vault data plane, it presents the wrong token. The fix is to ensure that when acquiring tokens for Key Vault, the resource is explicitly set to \`https://vault.azure.net\`. In the context of the Azure SDK or CLI, this means using a separate token request or ensuring the scope is correct. For Terraform, this often means ensuring the provider block correctly handles the separate resource endpoints or using specific authentication overrides for the Key Vault resource.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:19:37.384380+00:00— report_created — created