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

ModuleNotFoundError: No module named 'azure.storage.cloudstorageaccount' #701

Open
youssefbenfarhat opened this issue May 4, 2022 · 2 comments

Comments

@youssefbenfarhat
Copy link

youssefbenfarhat commented May 4, 2022

I'm always getting this error when I'm trying to integrate Ansible with Azure:
File "/tmp/ansible_azure_rm_resourcegroup_payload_qkhbne1k/ansible_azure_rm_resourcegroup_payload.zip/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 249, in
from azure.storage.cloudstorageaccount import CloudStorageAccount
ModuleNotFoundError: No module named 'azure.storage.cloudstorageaccount'
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"ad_user": null,
"adfs_authority_url": null,
"api_profile": "latest",
"append_tags": true,
"auth_source": "auto",
"cert_validation_mode": null,
"client_id": null,
"cloud_environment": "AzureCloud",
"force_delete_nonempty": false,
"location": "eastus",
"log_mode": null,
"log_path": null,
"name": "myResourceGroup",
"password": null,
"profile": null,
"secret": null,
"state": "present",
"subscription_id": null,
"tags": null,
"tenant": null
}
},
"msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on vmi576440.contaboserver.net's Python /home/yf/miniconda3/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

This is my requirements file:
packaging
requests[security]
azure-cli-core==2.0.35
azure-cli-nspkg==3.0.2
azure-common==1.1.11
azure-mgmt-authorization==0.51.1
azure-mgmt-batch==5.0.1
azure-mgmt-cdn==3.0.0
azure-mgmt-compute==4.4.0
azure-mgmt-containerinstance==1.4.0
azure-mgmt-containerregistry==2.0.0
azure-mgmt-containerservice==4.4.0
azure-mgmt-dns==2.1.0
azure-mgmt-keyvault==1.1.0
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-monitor==0.5.2
azure-mgmt-network==2.3.0
azure-mgmt-nspkg==2.0.0
azure-mgmt-redis==5.0.0
azure-mgmt-resource==2.1.0
azure-mgmt-rdbms==1.4.1
azure-mgmt-servicebus==0.5.3
azure-mgmt-sql==0.10.0
azure-mgmt-storage==3.1.0
azure-mgmt-trafficmanager==0.50.0
azure-mgmt-web==0.41.0
azure-nspkg==2.0.0
azure-storage==0.35.1
msrest==0.6.1
msrestazure==0.5.0
azure-keyvault==1.0.0a1
azure-graphrbac==0.40.0
azure-mgmt-cosmosdb==0.5.2
azure-mgmt-hdinsight==0.1.0
azure-mgmt-devtestlabs==3.0.0
azure-mgmt-loganalytics==0.2.0

@ahmedsza
Copy link

same issue and it can repro with a simple scenario running in cloud shell. https://learn.microsoft.com/en-us/azure/developer/ansible/getting-started-cloud-shell?tabs=ansible

@TimPollard
Copy link

TimPollard commented Sep 29, 2022

I was hitting the same issue. It seems to be because I had the wrong version of azure-storage or azure-storage-common installed.

The Azure collection docs say that you have to use pip to install the included requirements-azure.txt file:

Install dependencies required by the collection (adjust path to collection if necessary):
pip install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt

The latest version at time of writing is 1.13.0, which includes this requirements file: https://github.com/ansible-collections/azure/blob/v1.13.0/requirements-azure.txt

Weirdly azure-storage is the same version as in your requirements.txt, though perhaps the issue is azure-mgmt-storage, which is 19.0.0 instead of the 3.1.0 you are using? Or maybe you aren't using version 1.13.0 of the collection?

For me clearing out all the pip packages in my venv and then installing the ones from the collections requirements-azure.txt fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants