{"record":{"id":"4f8b055f7ee35629","repo":"microsoft/graphrag","slug":"azureblobstorage-requires-only-one-of-connection-s","errorCode":null,"errorMessage":"AzureBlobStorage requires only one of connection_string or account_url to be specified, not both.","messagePattern":"AzureBlobStorage requires only one of connection_string or account_url to be specified, not both\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-storage/graphrag_storage/azure_blob_storage.py","lineNumber":47,"sourceCode":"    _encoding: str\n    _account_url: str | None\n    _blob_service_client: BlobServiceClient\n    _storage_account_name: str | None\n\n    def __init__(\n        self,\n        container_name: str,\n        account_url: str | None = None,\n        connection_string: str | None = None,\n        base_dir: str | None = None,\n        encoding: str = \"utf-8\",\n        **kwargs: Any,\n    ) -> None:\n        \"\"\"Create a new BlobStorage instance.\"\"\"\n        if connection_string is not None and account_url is not None:\n            msg = \"AzureBlobStorage requires only one of connection_string or account_url to be specified, not both.\"\n            logger.error(msg)\n            raise ValueError(msg)\n\n        _validate_blob_container_name(container_name)\n\n        logger.info(\n            \"Creating blob storage at [%s] and base_dir [%s]\",\n            container_name,\n            base_dir,\n        )\n        if connection_string:\n            self._blob_service_client = BlobServiceClient.from_connection_string(\n                connection_string\n            )\n        elif account_url:\n            self._blob_service_client = BlobServiceClient(\n                account_url=account_url,\n                credential=DefaultAzureCredential(),\n            )\n        else:","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-storage/graphrag_storage/azure_blob_storage.py#L29-L65","documentation":"AzureBlobStorage.__init__ accepts either connection_string (for key-based auth) or account_url (for token/DefaultAzureCredential auth). Supplying both makes the chosen auth path ambiguous, so the constructor logs and raises ValueError before creating the client.","triggerScenarios":"Instantiating AzureBlobStorage(container_name=..., connection_string=..., account_url=...) with both values non-None, often because settings loaders pass every non-empty env var through.","commonSituations":"A .env / settings object where both GRAPHRAG_STORAGE_CONNECTION_STRING and a storage account URL variable are set (e.g. leftover from switching from key auth to managed identity), or a generic kwargs-from-config constructor.","solutions":["Remove or unset one of the two credentials (usually drop connection_string when moving to DefaultAzureCredential)","Audit .env / CI secrets for both variables being populated","Default the unused parameter to None explicitly at the call site"],"exampleFix":"# before\nstorage = AzureBlobStorage(\n    container_name='mycontainer',\n    connection_string=conn_str,\n    account_url='https://mystorage.blob.core.windows.net',\n)\n\n# after\nstorage = AzureBlobStorage(\n    container_name='mycontainer',\n    account_url='https://mystorage.blob.core.windows.net',  # uses DefaultAzureCredential\n)","handlingStrategy":"validation","validationCode":"assert not (connection_string and account_url), \"pass only one of connection_string / account_url\"\nif account_url:\n    connection_string = None","typeGuard":"null","tryCatchPattern":"try:\n    s = AzureBlobStorage(container_name=c, connection_string=cs, account_url=url)\nexcept ValueError as e:\n    if 'not both' in str(e):\n        s = AzureBlobStorage(container_name=c, account_url=url)  # prefer managed identity\n    else:\n        raise","preventionTips":["In settings classes, make connection_string and account_url mutually exclusive (validate on load)","Clear unused credential env vars when switching auth modes"],"tags":["azure","blob-storage","config","auth"],"backgroundTag":"conflicting-credentials-supplied","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}