Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions storages/backends/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ def _get_service_client(self):
DeprecationWarning,
)
options["api_version"] = self.api_version

# allow account url override for very custom azure instances/routing
if "account_url" in options:
return BlobServiceClient(credential=credential, **options)

return BlobServiceClient(account_url, credential=credential, **options)

@property
Expand Down
12 changes: 12 additions & 0 deletions tests/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ def test_container_client_params_token_credential(self):
"https://test.blob.core.windows.net", credential="foo_cred"
)

def test_container_client_params_token_credential_and_super_custom_url(self):
storage = azure_storage.AzureStorage()
storage.token_credential = "foo_cred"
storage.client_options = {"account_url": "https://bar.com"}
with mock.patch(
"storages.backends.azure_storage.BlobServiceClient", autospec=True
) as bsc_mocked:
client_mock = mock.MagicMock()
bsc_mocked.return_value.get_container_client.return_value = client_mock
self.assertEqual(storage.client, client_mock)
bsc_mocked.assert_called_once_with("https://bar.com", credential="foo_cred")

def test_connection_string_can_have_missing(self):
storage = azure_storage.AzureStorage(
connection_string="AccountKey=abc;Foobar=xyz;"
Expand Down