Error Encountered with 'az cloud register' when Adding ARM Endpoint and API Version #28716
Labels
Auto-Resolve
Auto resolve by bot
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
This issue is responsible by Azure service team.
Describe the bug
I've been trying to use az cloud register, and I'm hitting an error. Whenever I try to add a cloud with its ARM endpoint, I encounter an error. For instance, attempting to register AzureCloud with the AzureCloud ARM endpoint and API version throws an error.
Upon digging deeper, I found that in azure-cli/src/azure-cli/azure/cli/command_modules/cloud/custom.py, there's a function called _build_cloud (link). This function relies on msrestazure, which has been deprecated. It eventually calls msrestazure.azure_cloud._populate_from_metadata_endpoint (link).
Inside _populate_from_metadata_endpoint, there's an API call to the given ARM endpoint, where the error occurs. It seems like the ARM endpoint is expected to not include the API version, so including it causes a hiccup. Additionally, _populate_from_metadata_endpoint uses a hardcoded API version, which is outdated by now (link).
I'm a bit lost on how to tackle this bug. The msrestazure package has been split into azure-mgmt-core and azure-identity, but I haven't found a direct replacement for its functionality.
I'm keen to chip in and fix this issue, but I'd love your thoughts on the best approach.
Also, just an observation: Az PowerShell supports any version of the ARM endpoint from my experience, unlike what the CLI currently allows (link).
Related command
az cloud register --name "AzureCloud" --endpoint-resource-manager "https://management.azure.com/metadata/endpoints?api-version=2019-05-01"
Errors
The stacktrace leads to azure_cloud.py in msrestazure and the error is:
AttributeError: 'list' object has no attribute 'get'
This error goes away when you use the domain name rather than including the API version in "https://management.azure.com/metadata/endpoints?api-version=2019-05-01".
Issue script & Debug output
N/A
Expected behavior
I expect it to register the cloud or tell me the cloud was already registered. I use AzureCloud as an example of this failure.
Environment Summary
azure-cli versions: 2.58.0
core: 2.58.0
telemetry: 1.1.0
msal: 1.26.0
azure-mgmt-resource: 23.1.0b2.
I have also seen this issue in azure-cli: 2.57.0
Additional context
No response
The text was updated successfully, but these errors were encountered: