This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""The Azure Storage Block Blob backend for Celery."""
|
||||
from kombu.transport.azurestoragequeues import Transport as AzureStorageQueuesTransport
|
||||
from kombu.utils import cached_property
|
||||
from kombu.utils.encoding import bytes_to_str
|
||||
|
||||
@@ -28,6 +29,13 @@ class AzureBlockBlobBackend(KeyValueStoreBackend):
|
||||
container_name=None,
|
||||
*args,
|
||||
**kwargs):
|
||||
"""
|
||||
Supported URL formats:
|
||||
|
||||
azureblockblob://CONNECTION_STRING
|
||||
azureblockblob://DefaultAzureCredential@STORAGE_ACCOUNT_URL
|
||||
azureblockblob://ManagedIdentityCredential@STORAGE_ACCOUNT_URL
|
||||
"""
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if azurestorage is None or azurestorage.__version__ < '12':
|
||||
@@ -65,11 +73,26 @@ class AzureBlockBlobBackend(KeyValueStoreBackend):
|
||||
the container is created if it doesn't yet exist.
|
||||
|
||||
"""
|
||||
client = BlobServiceClient.from_connection_string(
|
||||
self._connection_string,
|
||||
connection_timeout=self._connection_timeout,
|
||||
read_timeout=self._read_timeout
|
||||
)
|
||||
if (
|
||||
"DefaultAzureCredential" in self._connection_string or
|
||||
"ManagedIdentityCredential" in self._connection_string
|
||||
):
|
||||
# Leveraging the work that Kombu already did for us
|
||||
credential_, url = AzureStorageQueuesTransport.parse_uri(
|
||||
self._connection_string
|
||||
)
|
||||
client = BlobServiceClient(
|
||||
account_url=url,
|
||||
credential=credential_,
|
||||
connection_timeout=self._connection_timeout,
|
||||
read_timeout=self._read_timeout,
|
||||
)
|
||||
else:
|
||||
client = BlobServiceClient.from_connection_string(
|
||||
self._connection_string,
|
||||
connection_timeout=self._connection_timeout,
|
||||
read_timeout=self._read_timeout,
|
||||
)
|
||||
|
||||
try:
|
||||
client.create_container(name=self._container_name)
|
||||
|
||||
Reference in New Issue
Block a user