ImportError: cannot import name 'BlobService' when using Azure Backend

I had to downgrade to azure-storage-0.20.0 which fixed the issue, the newer versions couldn't find the BlobService class.


In newer versions of azure-storage-blob the import BlockBlobService has been renamed to BlobServiceClient.

Updating your import statement to below should resolve your issue:

from azure.storage.blob import BlobServiceClient

An example of this can seen in the documentation here.


When you pip install azure, you installed azure-storage 0.34.3 (tutorial 1). When you followed the second tutorial, you installed azure-storage-blob 0.37.0. This is where you got issues, there is massive breaking changes in 0.37.0 in the namespaces:

https://github.com/Azure/azure-storage-python/blob/master/BreakingChanges.md#version-0370

See in the ChangeLog that azure-storage <= 0.36 is incompatible with azure-storage-blob >= 0.37. You silently replaced some code file of 0.34.3 by 0.37.0 version.

In you second test, you said you did:

pip3 install azure-storage-blob
pip3 install azure

Package are still incompatible, but you did it in a reverse order, where you crushed your 0.37.0 version with the 0.34.3 one this time. It's why it works.

TLDR, someone needs to update django-storages to support azure-storage-blob >= 0.37.0. In the mean time, stick to azure-storage <= 0.36 and DON'T install azure-storage-blob at all.