dotnet/runtime · error · RuntimeError

Missing Azure Storage package.

Error message

Missing Azure Storage package.

What it means

Thrown by require_azure_storage_libraries() in jitutil.py when either azure-storage-blob or azure-identity Python packages fail to import. This is a lazy check: the function is called only when Azure SDK APIs are actually needed (authenticated downloads/uploads), and it caches the result so it only checks once per process.

Source

Thrown at src/coreclr/scripts/jitutil.py:596

        except:
            azure_storage_blob_import_ok = False

    azure_identity_import_ok = True
    if need_azure_identity:
        try:
            from azure.identity import AzureCliCredential
        except:
            azure_identity_import_ok = False

    if not azure_storage_blob_import_ok or not azure_identity_import_ok:
        logging.error("One or more required Azure Storage packages is missing.")
        logging.error("")
        logging.error("Please install:")
        logging.error("  pip install azure-storage-blob azure-identity")
        logging.error("or (Windows):")
        logging.error("  py -3 -m pip install azure-storage-blob azure-identity")
        logging.error("See also https://learn.microsoft.com/azure/storage/blobs/storage-quickstart-blobs-python")
        raise RuntimeError("Missing Azure Storage package.")

    # The Azure packages spam all kinds of output to the logging channels.
    # Restrict this to only ERROR and CRITICAL.
    for name in logging.Logger.manager.loggerDict.keys():
        if 'azure' in name:
            logging.getLogger(name).setLevel(logging.ERROR)


def report_azure_error():
    """ Report an Azure error
    """
    logging.error("A problem occurred accessing Azure. Are you properly authenticated using the Azure CLI?")
    logging.error("Install the Azure CLI from https://learn.microsoft.com/cli/azure/install-azure-cli.")
    logging.error("Then log in to Azure using `az login`.")


def download_with_azure(uri, target_location, fail_if_not_found=True):
    """ Do an URI download using Azure blob storage API. Compared to urlretrieve,

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Install both packages: 'pip install azure-storage-blob azure-identity'.
  2. Verify import works: 'python -c "from azure.storage.blob import BlobServiceClient; from azure.identity import AzureCliCredential"'.
  3. If using a virtualenv, ensure it is activated before running the script.
  4. Run 'az login' to authenticate after installing packages.

Example fix

# before: missing packages
python superpmi.py asmdiffs
# -> RuntimeError: Missing Azure Storage package.

# after: install and authenticate
pip install azure-storage-blob azure-identity
az login
python superpmi.py asmdiffs
Defensive patterns

Strategy: validation

Validate before calling

# Check Azure packages before calling functions that need them
import importlib
def azure_libraries_available():
    try:
        importlib.import_module('azure.storage.blob')
        importlib.import_module('azure.identity')
        return True
    except ImportError:
        return False

if not azure_libraries_available():
    print('Missing Azure packages. Run: pip install azure-storage-blob azure-identity')

Type guard

def has_azure_storage_packages() -> bool:
    try:
        import azure.storage.blob.BlobServiceClient  # noqa
        import azure.identity.AzureCliCredential      # noqa
        return True
    except ImportError:
        return False

Try / catch

try:
    require_azure_storage_libraries()
except RuntimeError as e:
    if 'Missing Azure Storage' in str(e):
        import subprocess
        subprocess.run(['pip', 'install', 'azure-storage-blob', 'azure-identity'], check=True)
        require_azure_storage_libraries()  # retry after install
    raise

Prevention

When it happens

Trigger: require_azure_storage_libraries() is called from download_with_azure() or from scripts that need BlobServiceClient/BlobClient/ContainerClient/AzureCliCredential. If the try/except for 'from azure.storage.blob import ...' or 'from azure.identity import AzureCliCredential' catches an ImportError, line 596 raises with pip install instructions.

Common situations: Fresh Python environment without Azure SDK installed. The packages are installed in a different Python environment than the one running the script. Corporate environment blocks pip installs. Package version incompatibility causing import errors even when installed.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/7d08c1af38b8fd0f. Report an issue: GitHub.