Skip to content

Commit

Permalink
Add AZURE_CLIENT_OPTIONS setting
Browse files Browse the repository at this point in the history
This allows users to customize the kwarg options for the
BlobServiceClient.

This change also deprecates the AZURE_API_VERSION setting as well.
  • Loading branch information
daviddavis committed Jul 17, 2024
1 parent b37d53e commit 174fab4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions docs/backends/azure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,23 @@ Settings

Default: ``None``

**Note: This options is deprecated. Use client_options/AZURE_CLIENT_OPTIONS instead.**

The Azure Storage API version to use. Default value is the most recent service version that is compatible with the current SDK.
Setting to an older version may result in reduced feature compatibility.

``client_options`` or ``AZURE_CLIENT_OPTIONS``

Default: ``{}``

A dict of kwarg options to send to the ``BlobServiceClient``. A partial list of options can be
found at
<https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient?view=azure-python#keyword-only-parameters>.

This setting can be used to configure the client retry settings. More info at
<https://learn.microsoft.com/en-us/azure/storage/blobs/storage-retry-policy-python>.


Using with Azurite (previously Azure Storage Emulator)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 3 additions & 1 deletion storages/backends/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def get_default_settings(self):
"connection_string": setting("AZURE_CONNECTION_STRING"),
"token_credential": setting("AZURE_TOKEN_CREDENTIAL"),
"api_version": setting("AZURE_API_VERSION", None),
"client_options": setting("AZURE_CLIENT_OPTIONS", {}),
}

def _get_service_client(self):
Expand All @@ -171,8 +172,9 @@ def _get_service_client(self):
credential = self.sas_token
elif self.token_credential:
credential = self.token_credential
options = {}
options = self.client_options
if self.api_version:
# api_version is deprecated as users can set it via AZURE_CLIENT_OPTIONS
options["api_version"] = self.api_version
return BlobServiceClient(account_url, credential=credential, **options)

Expand Down

0 comments on commit 174fab4

Please sign in to comment.