Azure / azure-cli

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

storageAccount: AZ Cli returning Error while Powershell works #29934

Open jhr1972 opened 1 month ago

jhr1972 commented 1 month ago

Describe the bug

Hi, I am trying to use a simple query that keeps bombing out:

az storage share list --account-name XXXXXX --debug

returning the following error:

cli.azure.cli.core.profiles._shared: Traceback (most recent call last):

File "/usr/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 656, in _get_attr

op = import_module(full_mod_path)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

` File "

When querying via Powershell things work fine:

Get-AzRmStorageShare -ResourceGroupName YYYYY -StorageAccountName XXXXX

Please note, the same error occurs also in the cloud shell, so I doubt this issue is specific to my environment. To replicate the issue the storageAccount needs to have public access disabled.

Related command

az storage share list --account-name XXXXXX --debug

resp.

Get-AzRmStorageShare -ResourceGroupName YYYYY -StorageAccountName XXXXX

Errors

az storage share list --account-name XXXXXX --debug

returning the following error:


cli.azure.cli.core.profiles._shared: Traceback (most recent call last):

File "/usr/lib/python3.12/site-packages/azure/cli/core/profiles/_shared.py", line 656, in _get_attr

op = import_module(full_mod_path)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

### Issue script & Debug output

To replicate the issue, setup a private stroageAccount and try listing the shares within.
More details are also provided here: https://learn.microsoft.com/en-us/answers/questions/2072016/az-cli-returning-error-while-powershell-works

### Expected behavior

I ran into error via Terraform (relying on the same python modules) which is incapable to create a share as it seems to query for existing shares first.

### Environment Summary

az --version
azure-cli                         2.64.0

core                              2.64.0
telemetry                          1.1.0

Extensions:
ai-examples                        0.2.5
ml                                2.29.0
ssh                                2.0.5

Dependencies:
msal                              1.30.0
azure-mgmt-resource               23.1.1

Python location '/usr/bin/python3.9'
Extensions directory '/home/xxx/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.19 (main, Aug 23 2024, 00:07:48) 
[GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

To replicate the issue the storageAccount needs to have public access disabled. 
yonzhan commented 1 month ago

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