HumanSignal/label-studio · error · ValueError
Azure account name and key must be set using environment var
Error message
Azure account name and key must be set using environment variables AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY
What it means
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.
Source
Thrown at label_studio/io_storages/azure_blob/utils.py:119
metadata = {
'ETag': getattr(properties, 'etag', ''),
'ContentLength': content_length,
'ContentRange': f'bytes {start}-{actual_end}/{total_size or 0}',
'LastModified': getattr(properties, 'last_modified', None),
'StatusCode': status_code,
}
return downloader, resolved_content_type, metadata
@classmethod
def get_client_and_container(cls, container, account_name=None, account_key=None):
# get account name and key from params or from environment variables
account_name = str(account_name) if account_name else get_env('AZURE_BLOB_ACCOUNT_NAME')
account_key = str(account_key) if account_key else get_env('AZURE_BLOB_ACCOUNT_KEY')
# check that both account name and key are set
if not account_name or not account_key:
raise ValueError(
'Azure account name and key must be set using '
'environment variables AZURE_BLOB_ACCOUNT_NAME and AZURE_BLOB_ACCOUNT_KEY'
)
connection_string = (
'DefaultEndpointsProtocol=https;AccountName='
+ account_name
+ ';AccountKey='
+ account_key
+ ';EndpointSuffix=core.windows.net'
)
client = BlobServiceClient.from_connection_string(conn_str=connection_string)
container = client.get_container_client(str(container))
return client, container
@classmethod
def get_blob_metadata(cls, url: str, container: str, account_name: str = None, account_key: str = None) -> dict:
"""
Get blob metadata by urlView on GitHub (pinned to 0b49e9b539)
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.
Example fix
// before # env: nothing set cls.get_client_and_container(container='mycontainer') // after export AZURE_BLOB_ACCOUNT_NAME=mystorageaccount export AZURE_BLOB_ACCOUNT_KEY=<base64-key> # or cls.get_client_and_container(container='mycontainer', account_name='mystorageaccount', account_key='<base64-key>')
Defensive patterns
Strategy: validation
Validate before calling
import os
missing = [v for v in ('AZURE_BLOB_ACCOUNT_NAME', 'AZURE_BLOB_ACCOUNT_KEY') if not os.environ.get(v)]
if missing:
raise EnvironmentError(f'Missing Azure Blob env vars: {missing}') Type guard
def has_azure_credentials() -> bool:
return bool(os.environ.get('AZURE_BLOB_ACCOUNT_NAME')) and bool(os.environ.get('AZURE_BLOB_ACCOUNT_KEY')) Try / catch
try:
client, container = AzureBlobStorage.get_client_and_container(container)
except ValueError as e:
if 'AZURE_BLOB_ACCOUNT' in str(e):
raise StorageConfigError('Set AZURE_BLOB_ACCOUNT_NAME/AZURE_BLOB_ACCOUNT_KEY env vars') from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Azure account name and key must be set using environment var
- When "FEATURE_FLAGS_FROM_FILE" is set, you have to specify a
- SECURE_PROXY_SSL_HEADER must be configured as "<header>,<val
- Environment variable {key} must be an integer, got: {value}
- "form_layout.yml" is not found for {self.__class__.__name__}
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/0eb5306549b0b460.
Report an issue: GitHub.