Azure Blobs Storage Driver Documentation
Connecting to Azure Blobs
To connect to Azure Blobs you need your storage account name and access key.
You can retrieve this information in the Azure Management Portal by going to “Storage Accounts” -> “Access Keys” as shown on the screenshots below.
The following types of storage accounts are supported in libcloud:
Instantiating a driver
Once you have obtained your credentials you can instantiate the driver as shown below.
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
cls = get_driver(Provider.AZURE_BLOBS)
driver = cls(key="your storage account name", secret="your access key")
Connecting to Azure Government
To target an Azure Government storage account, you can instantiate the driver by setting a custom storage host argument as shown below.
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
cls = get_driver(Provider.AZURE_BLOBS)
driver = cls(
key="your storage account name",
secret="your access key",
host="blob.core.usgovcloudapi.net",
)
Setting a custom host argument can also be leveraged to customize the blob endpoint and connect to a storage account in Azure China or Azure Private Link.
Connecting to self-hosted Azure Storage implementations
To facilitate integration testing, libcloud supports connecting to the Azurite storage emulator. After starting the emulator, you can instantiate the driver as shown below.
from libcloud.storage.types import Provider
from libcloud.storage.providers import get_driver
cls = get_driver(Provider.AZURE_BLOBS)
driver = cls(
key="devstoreaccount1",
secret="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6"
"IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
host="localhost",
port=10000,
secure=False,
)
This instantiation strategy can also be adapted to connect to other self-hosted Azure Storage implementations such as Azure Blob Storage on IoT Edge.
Connecting with Azure AD
Create a service principal in the same tenant as your storage account. Once you have obtained your credentials you can instantiate the driver as shown below.
from build.lib.libcloud.storage.types import Provider
from build.lib.libcloud.storage.providers import get_driver
cls = get_driver(Provider.AZURE_BLOBS)
driver = cls(
key="your storage account name",
secret="your service principal secret key",
tenant_id="your tenant id",
identity="your service principal application id",
auth_type="azureAd",
)