microsoft/graphrag · error · ValueError
AzureBlobStorage requires either a connection_string or acco
Error message
AzureBlobStorage requires either a connection_string or account_url to be specified.
What it means
AzureBlobStorage.__init__ requires exactly one auth credential. If both connection_string and account_url are None, the else branch logs and raises ValueError because the BlobServiceClient cannot be constructed anonymously.
Source
Thrown at packages/graphrag-storage/graphrag_storage/azure_blob_storage.py:68
logger.info(
"Creating blob storage at [%s] and base_dir [%s]",
container_name,
base_dir,
)
if connection_string:
self._blob_service_client = BlobServiceClient.from_connection_string(
connection_string
)
elif account_url:
self._blob_service_client = BlobServiceClient(
account_url=account_url,
credential=DefaultAzureCredential(),
)
else:
msg = "AzureBlobStorage requires either a connection_string or account_url to be specified."
logger.error(msg)
raise ValueError(msg)
self._encoding = encoding
self._container_name = container_name
self._connection_string = connection_string
self._base_dir = base_dir
self._account_url = account_url
self._storage_account_name = (
account_url.split("//")[1].split(".")[0] if account_url else None
)
self._create_container()
def _create_container(self) -> None:
"""Create the container if it does not exist."""
if not self._container_exists():
container_name = self._container_name
container_names = [
container.name
for container in self._blob_service_client.list_containers()View on GitHub (pinned to f40e9a26ce)
Solutions
- Set the connection string env var or pass connection_string explicitly
- Alternatively pass account_url and rely on DefaultAzureCredential (managed identity / az login)
- Verify the settings loader actually maps the env var to the constructor argument
- Check the variable isn't only defined in a different .env file or shell session
Example fix
# before
storage = AzureBlobStorage(container_name='mycontainer') # no creds -> ValueError
# after
import os
storage = AzureBlobStorage(
container_name='mycontainer',
connection_string=os.environ['AZURE_STORAGE_CONNECTION_STRING'],
) Defensive patterns
Strategy: validation
Validate before calling
import os
conn = os.environ.get('AZURE_STORAGE_CONNECTION_STRING')
url = os.environ.get('AZURE_STORAGE_ACCOUNT_URL')
assert conn or url, "set AZURE_STORAGE_CONNECTION_STRING or AZURE_STORAGE_ACCOUNT_URL" Type guard
null
Try / catch
try:
s = AzureBlobStorage(container_name=c)
except ValueError as e:
if 'either a connection_string or account_url' in str(e):
raise RuntimeError(f'missing storage credentials: {e}') from e
raise Prevention
- Fail fast on missing storage env vars at app startup
- On Azure hosts, prefer account_url + DefaultAzureCredential so no secret is needed
When it happens
Trigger: Instantiating AzureBlobStorage with neither connection_string nor account_url, typically because the relevant env vars are missing or were read under the wrong names.
Common situations: Missing AZURE_STORAGE_CONNECTION_STRING (or the graphrag-specific equivalent) in .env, running in a fresh environment/CI without secrets, or renaming settings fields so None is passed through.
Related errors
- AzureBlobStorage requires only one of connection_string or a
- api_key should not be set when using Azure Managed Identity.
- Blob storage does yet not support listing keys.
- Container name must be between 3 and 63 characters long and
- No storage account blob url provided for blob storage.
AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27).
Data as JSON: /api/errors/0c27efbd296036b0.
Report an issue: GitHub.