"az costmanagement query" on GovCloud fails with azure-cli 2.24.2; works with azure cli 2.8.0
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
When using Azure Gov Cloud with azure-cli 2.24, this command
az costmanagement query --type "Usage" --timeframe "MonthToDate" --scope "subscriptions/..."
gives this this error:
(InvalidAuthenticationTokenAudience) The access token has been obtained for wrong audience or resource 'https://management.azure.com'. It should exactly match with one of the allowed audiences 'https://management.core.usgovcloudapi.net/','https://management.core.usgovcloudapi.net','https://management.usgovcloudapi.net/','https://management.usgovcloudapi.net'.
The same command worked fine with azure-cli 2.8.0. A workaround is to use
pip uninstall azure-cli
pip install azure-cli==2.8.0
which makes the command work again for me.
**To Reproduce**
Start with a clean system without the azure cli (I tried on both macos and ubuntu)
pip install -q --upgrade pip
pip install azure-cli
az cloud set --name AzureUSGovernment
az extension add --name costmanagement
az login
az costmanagement query --type "Usage" --timeframe "MonthToDate" --scope [one-of-your-subscriptions]
**Expected behavior**
It should give the results of the query --- exactly as it would if you replace the install command above with:
pip install azure-cli==2.8.0
**Environment summary**
Tried on MacOS and Ubuntu.
$ az version
{
"azure-cli": "2.24.2",
"azure-cli-core": "2.24.2",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"costmanagement": "0.1.1"
}
}
**Additional context**
The command worked fine with no errors with this config
$ az version
{
"azure-cli": "2.8.0",
"azure-cli-command-modules-nspkg": "2.0.3",
"azure-cli-core": "2.8.0",
"azure-cli-nspkg": "3.0.4",
"azure-cli-telemetry": "1.0.4",
"extensions": {
"costmanagement": "0.1.1",
"databricks": "0.3.0"
}
}
Contributor guide
Assessment
This issue has not been assessed yet.