{"record":{"id":"0c27efbd296036b0","repo":"microsoft/graphrag","slug":"azureblobstorage-requires-either-a-connection-stri","errorCode":null,"errorMessage":"AzureBlobStorage requires either a connection_string or account_url to be specified.","messagePattern":"AzureBlobStorage requires either a connection_string or account_url to be specified\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-storage/graphrag_storage/azure_blob_storage.py","lineNumber":68,"sourceCode":"\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:\n            msg = \"AzureBlobStorage requires either a connection_string or account_url to be specified.\"\n            logger.error(msg)\n            raise ValueError(msg)\n\n        self._encoding = encoding\n        self._container_name = container_name\n        self._connection_string = connection_string\n        self._base_dir = base_dir\n        self._account_url = account_url\n        self._storage_account_name = (\n            account_url.split(\"//\")[1].split(\".\")[0] if account_url else None\n        )\n        self._create_container()\n\n    def _create_container(self) -> None:\n        \"\"\"Create the container if it does not exist.\"\"\"\n        if not self._container_exists():\n            container_name = self._container_name\n            container_names = [\n                container.name\n                for container in self._blob_service_client.list_containers()","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-storage/graphrag_storage/azure_blob_storage.py#L50-L86","documentation":"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.","triggerScenarios":"Instantiating AzureBlobStorage with neither connection_string nor account_url, typically because the relevant env vars are missing or were read under the wrong names.","commonSituations":"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.","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"],"exampleFix":"# before\nstorage = AzureBlobStorage(container_name='mycontainer')  # no creds -> ValueError\n\n# after\nimport os\nstorage = AzureBlobStorage(\n    container_name='mycontainer',\n    connection_string=os.environ['AZURE_STORAGE_CONNECTION_STRING'],\n)","handlingStrategy":"validation","validationCode":"import os\nconn = os.environ.get('AZURE_STORAGE_CONNECTION_STRING')\nurl = os.environ.get('AZURE_STORAGE_ACCOUNT_URL')\nassert conn or url, \"set AZURE_STORAGE_CONNECTION_STRING or AZURE_STORAGE_ACCOUNT_URL\"","typeGuard":"null","tryCatchPattern":"try:\n    s = AzureBlobStorage(container_name=c)\nexcept ValueError as e:\n    if 'either a connection_string or account_url' in str(e):\n        raise RuntimeError(f'missing storage credentials: {e}') from e\n    raise","preventionTips":["Fail fast on missing storage env vars at app startup","On Azure hosts, prefer account_url + DefaultAzureCredential so no secret is needed"],"tags":["azure","blob-storage","auth","env-var"],"backgroundTag":"missing-storage-credentials","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}