Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

fix: pass account name explicitly for Azure Blob account key auth (#2454) (#2455)

Nathan Bakarefa6c13b22ed8
diff --git a/enhancements/connectors/azure_blob/auth.py b/enhancements/connectors/azure_blob/auth.py
index a30918123..c422da3fa 100644
--- a/enhancements/connectors/azure_blob/auth.py
+++ b/enhancements/connectors/azure_blob/auth.py
@@ -141,4 +141,9 @@ def create_blob_service_client(config: dict[str, Any]):
account=creds["account_name"]
)
logger.debug("Creating Azure Blob client with account key for %s", account_url)
- return BlobServiceClient(account_url=account_url, credential=creds["account_key"])
+ # Pass the account name explicitly: with a bare key string the SDK infers it
+ # from the URL, which fails for custom hostnames (e.g. http://azurite:10000/...).
+ return BlobServiceClient(
+ account_url=account_url,
+ credential={"account_name": creds["account_name"], "account_key": creds["account_key"]},
+ )
diff --git a/tests/unit/connectors/test_azure_blob_connector.py b/tests/unit/connectors/test_azure_blob_connector.py
index 05b9dcbb9..bf2ba59da 100644
--- a/tests/unit/connectors/test_azure_blob_connector.py
+++ b/tests/unit/connectors/test_azure_blob_connector.py
@@ -114,6 +114,31 @@ def test_create_client_account_key_mode_with_endpoint(monkeypatch):
assert client is not None
+ "endpoint_url",
+ [
+ # Azurite reached by its Docker service name.
+ "http://azurite:10000/devstoreaccount1",
+ # Custom domain / private endpoint with no account name in the host.
+ "https://storage.internal.example.com",
+ ],
+)
+def test_create_client_account_key_mode_custom_hostname_endpoint(monkeypatch, endpoint_url):
+ # The SDK cannot infer the account name from these URLs, so the client
+ # must be given it explicitly instead of a bare key string.
+ _clear_azure_env(monkeypatch)
+ client = az_auth.create_blob_service_client(
+ {
+ "auth_mode": "account_key",
+ "account_name": "devstoreaccount1",
+ "account_key": "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT==",
+ "endpoint_url": endpoint_url,
+ }
+ )
+ assert client.account_name == "devstoreaccount1"
+ assert client.credential.account_name == "devstoreaccount1"
+
+
def test_create_client_connection_string_missing_raises(monkeypatch):
_clear_azure_env(monkeypatch)
with pytest.raises(ValueError, match="Connection string mode requires"):