AZ Cli returning Error while Powershell works

JR-Azure 25 Reputation points
2024-09-17T10:40:55.75+00:00

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.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,224 questions
{count} vote

Accepted answer
  1. Nehruji R 8,146 Reputation points Microsoft Vendor
    2024-09-18T06:42:32.2966667+00:00

    Hello JR-Azure,

    Greetings! Welcome to Microsoft Q&A Platform.

    I understand that you are encountering an issue while fetching the storage account list via Azure CLI and getting error message.

    Adding to below information, please consider checking this following troubleshooting doc for more details on resolution.

    Also, when you disabled the public access to storage account then you must enable "Allow Azure services on the trusted services list to access this storage account" in the networking tab of the Storage Account.

    1. Verify "Allow Azure services on the trusted services list to access this storage account" checkbox is selected
    2. Whitelist the client IPs by adding the client's Public IP to the Storage Firewall and give it a check?

    Similar issue thread for reference - https://github.com/Azure/azure-cli/issues/29904,

    https://github.com/Azure/azure-cli/issues/28153

    Hope this information helps! please let us know if you have any further queries. I’m happy to assist you further.

    Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Vinodh247 23,346 Reputation points MVP
    2024-09-17T12:09:04.02+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    • The error you're encountering with the Azure CLI (az storage share list --account-name XXXXXX --debug) is due to a missing Python module in your CLI environment. Specifically, it cannot find the azure.mgmt.storage.v2023_01_01.models.storage_account_keys module, which points to a version mismatch or incomplete installation of the Azure SDK components required by the CLI.

    az version az upgrade az extension update --name storage-preview

    • If upgrading doesn't resolve the issue, it's possible that the current installation is corrupted., hence try reinstalling it.
    • The Get-AzRmStorageShare cmdlet works because powerShell uses a different set of underlying libraries and dependencies, which might not have the version mismatch issue seen in the CLI. PowerShell manages Azure resources through the Az module, which is independent of the Azure CLI.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.


  2. JR-Azure 25 Reputation points
    2024-09-19T06:31:07.3566667+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.