Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.99k forks source link

az cli command shows the azure resource , the id field string case is wrong #26817

Closed baoj-dfo closed 1 year ago

baoj-dfo commented 1 year ago

Describe the bug

one example: az acr scope-map list the RG name of id field turn into small case, while my RG name in Azure is capital case.

Related command

az acr scope-map list -r $name

Errors

scopeMaps's "id" field: /subscriptions/*/resourceGroups/deploy-dev-rg/providers/Microsoft.ContainerRegistry/registries/"

wrong id case will cause the later Terraform import command fail

Issue script & Debug output

az acr scope-map list -r $name

Expected behavior

scopeMaps's "id" field with correct RG name (same case as what defined in Azure portal): /subscriptions/*/resourceGroups/DEPLOY-DEV-RG/providers/Microsoft.ContainerRegistry/registries/"

Environment Summary

azure-cli 2.49.0

core 2.49.0 telemetry 1.0.8

Extensions: amg 1.2.3 authV2 0.1.2 azure-devops 0.26.0 containerapp 0.3.29 cosmosdb-preview 0.24.0 datafactory 0.7.0 ssh 1.1.3

Dependencies: msal 1.20.0 azure-mgmt-resource 22.0.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Additional context

No response

yonzhan commented 1 year ago

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

estebanreyl commented 1 year ago

Unfortunately, this confusing behavior is expected behavior. The Azure container registry command is using the ARM cache to obtain the resource group that is sent to the underlying API. This value is used in the response and is given to us in lowercase. ARM treats resource groups as case insensitive as specified in https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules as a result this is valid and terraform should take this into account ignoring case sensitivity for resource groups. That said, for this particular ACR API it is possible to bypass the ARM cache to make sure you get back the expected case, to do this specify the upper-cased resource group as a parameter such as: az acr scope-map list --registry myregistry -g MY-RG-GROUP.

estebanreyl commented 1 year ago

We can close this issue with Works as expected.

ghost commented 1 year ago

Hi @baoj-dfo. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

SaurabhSharma-MSFT commented 1 year ago

@baoj-dfo We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.