{"record":{"id":"0eb5306549b0b460","repo":"HumanSignal/label-studio","slug":"azure-account-name-and-key-must-be-set-using-envir-0eb530","errorCode":null,"errorMessage":"Azure account name and key must be set using environment variables AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY","messagePattern":"Azure account name and key must be set using environment variables AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/io_storages/azure_blob/utils.py","lineNumber":119,"sourceCode":"\n        metadata = {\n            'ETag': getattr(properties, 'etag', ''),\n            'ContentLength': content_length,\n            'ContentRange': f'bytes {start}-{actual_end}/{total_size or 0}',\n            'LastModified': getattr(properties, 'last_modified', None),\n            'StatusCode': status_code,\n        }\n\n        return downloader, resolved_content_type, metadata\n\n    @classmethod\n    def get_client_and_container(cls, container, account_name=None, account_key=None):\n        # get account name and key from params or from environment variables\n        account_name = str(account_name) if account_name else get_env('AZURE_BLOB_ACCOUNT_NAME')\n        account_key = str(account_key) if account_key else get_env('AZURE_BLOB_ACCOUNT_KEY')\n        # check that both account name and key are set\n        if not account_name or not account_key:\n            raise ValueError(\n                'Azure account name and key must be set using '\n                'environment variables AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY'\n            )\n        connection_string = (\n            'DefaultEndpointsProtocol=https;AccountName='\n            + account_name\n            + ';AccountKey='\n            + account_key\n            + ';EndpointSuffix=core.windows.net'\n        )\n        client = BlobServiceClient.from_connection_string(conn_str=connection_string)\n        container = client.get_container_client(str(container))\n        return client, container\n\n    @classmethod\n    def get_blob_metadata(cls, url: str, container: str, account_name: str = None, account_key: str = None) -> dict:\n        \"\"\"\n        Get blob metadata by url","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/azure_blob/utils.py#L101-L137","documentation":"Label Studio's Azure Blob storage integration resolves the account name and key either from explicit parameters or from the AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY environment variables. get_client_and_container raises this ValueError when, after that fallback, either value is empty, because a BlobServiceClient connection string cannot be built without both credentials.","triggerScenarios":"Calling get_blob_metadata or validate_pattern (which both call get_client_and_container) when account_name/account_key params are None/empty AND the AZURE_BLOB_ACCOUNT_NAME or AZURE_BLOB_ACCOUNT_KEY environment variables are unset or empty.","commonSituations":"Deploying Label Studio without exporting the Azure env vars (or exporting them only in a different shell/container than the worker process); typo'd env var names; passing an empty string as account_name; Kubernetes/Docker secret not mounted into the environment.","solutions":["Set both AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY environment variables in the environment of the Label Studio process (verify with `printenv` inside the container/pod).","Alternatively pass account_name and account_key explicitly wherever the storage is configured/validated, e.g. via the storage settings API/JSON.","Check for typos in env var names and restart the process after adding them so the env is reloaded."],"exampleFix":"// before\n# env: nothing set\ncls.get_client_and_container(container='mycontainer')\n\n// after\nexport AZURE_BLOB_ACCOUNT_NAME=mystorageaccount\nexport AZURE_BLOB_ACCOUNT_KEY=<base64-key>\n# or\ncls.get_client_and_container(container='mycontainer', account_name='mystorageaccount', account_key='<base64-key>')","handlingStrategy":"validation","validationCode":"import os\nmissing = [v for v in ('AZURE_BLOB_ACCOUNT_NAME', 'AZURE_BLOB_ACCOUNT_KEY') if not os.environ.get(v)]\nif missing:\n    raise EnvironmentError(f'Missing Azure Blob env vars: {missing}')","typeGuard":"def has_azure_credentials() -> bool:\n    return bool(os.environ.get('AZURE_BLOB_ACCOUNT_NAME')) and bool(os.environ.get('AZURE_BLOB_ACCOUNT_KEY'))","tryCatchPattern":"try:\n    client, container = AzureBlobStorage.get_client_and_container(container)\nexcept ValueError as e:\n    if 'AZURE_BLOB_ACCOUNT' in str(e):\n        raise StorageConfigError('Set AZURE_BLOB_ACCOUNT_NAME/AZURE_BLOB_ACCOUNT_KEY env vars') from e\n    raise","preventionTips":["Set Azure credentials in deployment config (Docker/K8s secrets) and verify with a startup health check.","Pass account_name/account_key explicitly when configuring storage programmatically.","Check `printenv | grep AZURE` inside the exact process/container that runs syncs.","Watch for typos: the vars are AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY."],"tags":["azure","configuration","environment-variables","storage"],"backgroundTag":"missing-env-var","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}