Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Encountered with 'az cloud register' when Adding ARM Endpoint and API Version #28716

Open
rorozcov opened this issue Apr 9, 2024 · 3 comments
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.

Comments

@rorozcov
Copy link

rorozcov commented Apr 9, 2024

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

@rorozcov rorozcov added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Apr 9, 2024
Copy link

Hi @rorozcov,

2.57.0 is not the latest Azure CLI(2.59.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

@azure-client-tools-bot-prd azure-client-tools-bot-prd bot added the Auto-Resolve Auto resolve by bot label Apr 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Apr 9, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 9, 2024

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added Service Attention This issue is responsible by Azure service team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Apr 9, 2024
@jiasli
Copy link
Member

jiasli commented Jun 26, 2024

Previously there was an attempt #25834 to bump /metadata/endpoints API version from 2015-01-01 to 2022-09-01. However, that feature got suspended due to other high priority tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

3 participants