Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm trying to use the azure
get_client_from_cli_profile
to create the
ComputeClient
as I saw it on the
Azure docs
.
import os
from getpass import getpass
from azure.mgmt.compute import ComputeManagementClient
from azure.common.client_factory import get_client_from_cli_profile
login = input("Input your login : ")
pwd = getpass("Input your password : ")
print("Logging to azure...")
command = "az login -u {} -p {}".format(login, pwd)
os.system(command)
print("Logged in !")
print("Getting ressource client...")
resource_client = get_client_from_cli_profile(ComputeManagementClient)
print("Client acquired !")
However, I get an error during the get_client_from_cli_profile saying that azure-core is not installed…
Traceback (most recent call last):
File "test.py", line 14, in <module>
resource_client = get_client_from_cli_profile(ComputeManagementClient)
File "/usr/local/lib/python3.6/dist-packages/azure/common/client_factory.py", line 86, in get_client_from_cli_profile
with_tenant=True,
File "/usr/local/lib/python3.6/dist-packages/azure/common/credentials.py", line 99, in get_azure_cli_credentials
cred = _CliCredentials(profile, resource)
File "/usr/local/lib/python3.6/dist-packages/azure/common/credentials.py", line 50, in __init__
raise ImportError("You need to install 'azure-core' to use this feature")
ImportError: You need to install 'azure-core' to use this feature
Here's the package in my requierments :
azure-cli-core
azure
azure-core
I verified that the package was correctly installed and if I had the right to read the folder and file and all seems good to me :
$ pip3 show azure-core
Name: azure-core
Version: 1.2.2
Summary: Microsoft Azure Core Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: /home/non/.local/lib/python3.6/site-packages
Requires: six, requests
Required-by:
$ ls -la /usr/local/lib/python3.6/dist-packages/azure/common/
total 48
drwxrwsrwx 3 root staff 4096 févr. 27 10:54 .
drwxrwsrwx 19 root staff 4096 févr. 27 10:54 ..
-rwxrwxrwx 1 root staff 10452 févr. 27 10:54 client_factory.py
-rwxrwxrwx 1 root staff 755 févr. 27 10:54 cloud.py
-rwxrwxrwx 1 root staff 4256 févr. 27 10:54 credentials.py
-rwxrwxrwx 1 root staff 805 févr. 27 10:54 exceptions.py
-rwxrwxrwx 1 root staff 1358 févr. 27 10:54 __init__.py
drwxrwsrwx 2 root staff 4096 févr. 27 10:54 __pycache__
-rwxrwxrwx 1 root staff 328 févr. 27 10:54 _version.py
I tried with doing az login before lauching the script, it didn't change the outcome.
First, you should not need "azure-core" to use this method on a compute client, I created an issue for that:
https://github.com/Azure/azure-sdk-for-python/issues/10041
But still, you have "azure-core" installed as you show, so that 's troubling. Could you create an issue on the issue tracker so we can have a deeper conversation?
https://github.com/Azure/azure-sdk-for-python/issues
Edit: you actually hit this:
https://github.com/Azure/azure-sdk-for-python/issues/9195
Please do no use the "azure" meta-package that doesn't work with the current "azure-cli-core", but install "azure-mgmt-compute" instead, so you should have this installed:
azure-mgmt-compute
azure-cli-core
azure-core # Should not be necessary, bug 10041
Feel free to open an issue if that doesn't solve your problem
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.