Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.61k stars 2.83k forks source link

Sample for accessing blob storage with DefaultAzureCredential() doesn't work #8798

Closed jasonzio closed 4 years ago

jasonzio commented 4 years ago

Today (Nov 21) I used pip to install azure-identity and azure-storage-blob, then tried the sample code in the Readme for accessing storage using MSI credentials. The import of BlobServiceClient fails:

>>> from azure.storage.blob import BlobServiceClient
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'BlobServiceClient'

Python 3.5.3 on Debian Stretch

rakshith91 commented 4 years ago

@jasonzio Thanks for reporting! Can you do pip list and confirm what version of azure-storage-blob you are using? Even better, it'd be great if you can share the list here.

jasonzio commented 4 years ago

Here's the whole list:

adal (1.2.2)
azure (4.0.0)
azure-applicationinsights (0.1.0)
azure-batch (4.1.3)
azure-common (1.1.23)
azure-core (1.0.0)
azure-cosmosdb-nspkg (2.0.2)
azure-cosmosdb-table (1.0.6)
azure-datalake-store (0.0.48)
azure-eventgrid (1.3.0)
azure-graphrbac (0.40.0)
azure-identity (1.0.1)
azure-keyvault (1.1.0)
azure-loganalytics (0.1.0)
azure-mgmt (4.0.0)
azure-mgmt-advisor (1.0.1)
azure-mgmt-applicationinsights (0.1.1)
azure-mgmt-authorization (0.50.0)
azure-mgmt-batch (5.0.1)
azure-mgmt-batchai (2.0.0)
azure-mgmt-billing (0.2.0)
azure-mgmt-cdn (3.1.0)
azure-mgmt-cognitiveservices (3.0.0)
azure-mgmt-commerce (1.0.1)
azure-mgmt-compute (4.6.2)
azure-mgmt-consumption (2.0.0)
azure-mgmt-containerinstance (1.5.0)
azure-mgmt-containerregistry (2.8.0)
azure-mgmt-containerservice (4.4.0)
azure-mgmt-cosmosdb (0.4.1)
azure-mgmt-datafactory (0.6.0)
azure-mgmt-datalake-analytics (0.6.0)
azure-mgmt-datalake-nspkg (3.0.1)
azure-mgmt-datalake-store (0.5.0)
azure-mgmt-datamigration (1.0.0)
azure-mgmt-devspaces (0.1.0)
azure-mgmt-devtestlabs (2.2.0)
azure-mgmt-dns (2.1.0)
azure-mgmt-eventgrid (1.0.0)
azure-mgmt-eventhub (2.6.0)
azure-mgmt-hanaonazure (0.1.1)
azure-mgmt-iotcentral (0.1.0)
azure-mgmt-iothub (0.5.0)
azure-mgmt-iothubprovisioningservices (0.2.0)
azure-mgmt-keyvault (1.1.0)
azure-mgmt-loganalytics (0.2.0)
azure-mgmt-logic (3.0.0)
azure-mgmt-machinelearningcompute (0.4.1)
azure-mgmt-managementgroups (0.1.0)
azure-mgmt-managementpartner (0.1.1)
azure-mgmt-maps (0.1.0)
azure-mgmt-marketplaceordering (0.1.0)
azure-mgmt-media (1.0.0)
azure-mgmt-monitor (0.5.2)
azure-mgmt-msi (0.2.0)
azure-mgmt-network (2.7.0)
azure-mgmt-notificationhubs (2.1.0)
azure-mgmt-nspkg (3.0.2)
azure-mgmt-policyinsights (0.1.0)
azure-mgmt-powerbiembedded (2.0.0)
azure-mgmt-rdbms (1.9.0)
azure-mgmt-recoveryservices (0.3.0)
azure-mgmt-recoveryservicesbackup (0.3.0)
azure-mgmt-redis (5.0.0)
azure-mgmt-relay (0.1.0)
azure-mgmt-reservations (0.2.1)
azure-mgmt-resource (2.2.0)
azure-mgmt-scheduler (2.0.0)
azure-mgmt-search (2.1.0)
azure-mgmt-servicebus (0.5.3)
azure-mgmt-servicefabric (0.2.0)
azure-mgmt-signalr (0.1.1)
azure-mgmt-sql (0.9.1)
azure-mgmt-storage (2.0.0)
azure-mgmt-subscription (0.2.0)
azure-mgmt-trafficmanager (0.50.0)
azure-mgmt-web (0.35.0)
azure-nspkg (3.0.2)
azure-servicebus (0.21.1)
azure-servicefabric (6.3.0.0)
azure-servicemanagement-legacy (0.20.6)
azure-storage-blob (1.5.0)
azure-storage-common (1.4.2)
azure-storage-file (1.4.0)
azure-storage-queue (1.4.0)
certifi (2019.9.11)
cffi (1.13.2)
chardet (3.0.4)
cryptography (2.8)
idna (2.8)
isodate (0.6.0)
keyring (10.1)
keyrings.alt (1.3)
msal (1.0.0)
msal-extensions (0.1.3)
msrest (0.6.10)
msrestazure (0.6.2)
oauthlib (3.1.0)
pip (9.0.1)
portalocker (1.5.2)
pyasn1 (0.1.9)
pycparser (2.19)
pycrypto (2.6.1)
pycurl (7.43.0)
pygobject (3.22.0)
PyJWT (1.7.1)
python-apt (1.4.0b3)
python-dateutil (2.8.1)
pyxdg (0.25)
requests (2.22.0)
requests-oauthlib (1.3.0)
SecretStorage (2.3.1)
setuptools (33.1.1)
six (1.10.0)
unattended-upgrades (0.1)
urllib3 (1.25.7)
WALinuxAgent (2.2.34)
wheel (0.29.0)
rakshith91 commented 4 years ago

@jasonzio it seems like you have a very old version of the package (1.5.0). Please install the version 12.0.0 EDIT: You can do this by pip install azure-storage-blob --upgrade

Please let us know if you are still facing issues. If not, feel free to close the issue :)

jasonzio commented 4 years ago

I literally just installed python3-pip and then did "pip install"; if the version is really old, there's a tool chain problem someplace.

I'll uninstall all that junk and get the 12.x SDK.

jasonzio commented 4 years ago

Ah. Getting closer to my "root cause".

Is the pypi "azure" package obsolete?

rakshith91 commented 4 years ago

@jasonzio Short answer yes. We strongly discourage using "azure" package and recommend installing individual packages as you need them.

xiafu-msft commented 4 years ago

There was an email thread last Friday, I think @jasonzio got it working. Close this issue for now, feel free to reopen it if there is further questions!