{"id":5126,"library":"azure-storage-nspkg","title":"Azure Storage Namespace Package (Legacy V2 SDK)","description":"The `azure-storage-nspkg` package is an internal Microsoft Azure Storage namespace package, primarily associated with the V2 Python SDK for Azure Storage. This package served to define the `azure.storage` namespace, allowing older client libraries like `azure-storage-blob` (versions < 3), `azure-storage-file`, and `azure-storage-queue` to be imported under this common prefix. The V2 SDK is deprecated; users should migrate to the V12 SDK, which uses separate, hyphenated packages (e.g., `azure-storage-blob` version 12.x.x) and does not require or use `azure-storage-nspkg`.","status":"deprecated","version":"3.1.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-storage-python","tags":["azure","storage","cloud","deprecated","legacy","namespace"],"install":[{"cmd":"pip install azure-storage-nspkg","lang":"bash","label":"For V2 SDK (deprecated)"},{"cmd":"pip install azure-storage-blob azure-storage-file-share azure-storage-queue","lang":"bash","label":"For V12 SDK (recommended)"}],"dependencies":[],"imports":[{"note":"This was the primary service client for Blob Storage in V2 SDKs. The V12 SDK uses a different class and import path.","wrong":"This import pattern is from the V2 SDK, which is deprecated.","symbol":"BlockBlobService","correct":"from azure.storage.blob import BlockBlobService"},{"note":"This is the primary service client for Blob Storage in the V12 SDK. The `azure-storage-nspkg` is NOT required for V12 imports.","symbol":"BlobServiceClient","correct":"from azure.storage.blob import BlobServiceClient"}],"quickstart":{"code":"import os\nfrom azure.storage.blob import BlobServiceClient\n\nconnection_string = os.environ.get('AZURE_STORAGE_CONNECTION_STRING', 'DefaultEndpointsProtocol=https;AccountName=youraccount;AccountKey=yourkey;EndpointSuffix=core.windows.net')\n\ntry:\n    # Create the BlobServiceClient object which will be used to create a container client\n    blob_service_client = BlobServiceClient.from_connection_string(connection_string)\n\n    # Create a unique name for the container\n    container_name = 'quickstart-container-12345'\n    \n    # Create the container if it doesn't exist\n    try:\n        container_client = blob_service_client.create_container(container_name)\n        print(f\"Container '{container_name}' created successfully.\")\n    except Exception as e:\n        print(f\"Container '{container_name}' already exists or another error: {e}\")\n        container_client = blob_service_client.get_container_client(container_name)\n\n    # Example: List blobs in the container\n    print(\"Listing blobs...\")\n    blob_list = container_client.list_blobs()\n    for blob in blob_list:\n        print(f\"\\t{blob.name}\")\n\nexcept ValueError as e:\n    print(f\"Error: {e}. Please ensure AZURE_STORAGE_CONNECTION_STRING is set or configured correctly.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to connect to Azure Blob Storage using the *V12 SDK* (`azure-storage-blob` version 12.x.x), which is the currently recommended approach. This package (`azure-storage-nspkg`) is not required for the V12 SDK. Replace `youraccount` and `yourkey` with your actual Azure Storage account details or set the `AZURE_STORAGE_CONNECTION_STRING` environment variable."},"warnings":[{"fix":"Migrate your code to use the V12 SDK. Refer to the official Microsoft documentation for migration guides (search 'Migrate from Azure Storage SDK V2 to V12 Python'). Install `azure-storage-blob`, `azure-storage-file-share`, or `azure-storage-queue` directly.","message":"The Azure Storage SDK for Python has undergone a major redesign from V2 to V12. The V12 SDK introduces a completely new API surface, different package names (e.g., `azure-storage-blob` for V12 vs. `azure-storage-blob` for V2, but with different major version numbers), and improved idiomatic Python design. Code written for V2 will not work with V12 without significant refactoring.","severity":"breaking","affected_versions":"V2 SDK (e.g., `azure-storage-blob` < 3.0.0) vs. V12 SDK (`azure-storage-blob` >= 12.0.0)"},{"fix":"Avoid using `azure-storage-nspkg`. Install and use the V12 client libraries, such as `azure-storage-blob>=12.0.0`, `azure-storage-file-share>=12.0.0`, and `azure-storage-queue>=12.0.0`. These packages do not depend on or require `azure-storage-nspkg`.","message":"The `azure-storage-nspkg` package and the V2 Azure Storage SDK it supported are deprecated. Microsoft recommends using the V12 SDK for all new development and migrating existing applications.","severity":"deprecated","affected_versions":"All versions of `azure-storage-nspkg` and V2 related packages."},{"fix":"Always explicitly specify the major version when installing: `pip install azure-storage-blob==2.*` for V2 (legacy) or `pip install azure-storage-blob>=12` for V12 (recommended). For new projects, *only* install V12 packages and avoid `azure-storage-nspkg` entirely.","message":"The package name `azure-storage-blob` exists for both the legacy V2 SDK (versions < 3) and the current V12 SDK (versions >= 12). Installing `pip install azure-storage-blob` without specifying a version might lead to installing the V12 SDK, but if `azure-storage-nspkg` (or other V2 dependencies) is already present, version conflicts or unexpected behavior can occur if you intend to use V2.","severity":"gotcha","affected_versions":"All versions, due to ambiguous package naming across major versions."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}