Accessing Blobs

This guide covers various methods for accessing blobs in Azure Storage, including using the Azure portal, Azure CLI, Azure PowerShell, and client libraries.

1. Using the Azure Portal

The Azure portal provides a user-friendly interface to browse, upload, download, and manage your blobs and containers.

  1. Navigate to your storage account in the Azure portal.
  2. Under the Data storage section, select Containers.
  3. Click on the desired container.
  4. You can then see a list of blobs within the container. Click on a blob to view its properties, download it, or perform other actions.

2. Using Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for managing Azure resources, including blob storage.

To list blobs in a container:

az storage blob list --account-name  --container-name  --output table

To download a blob:

az storage blob download --account-name  --container-name  --name  --file 

To upload a blob:

az storage blob upload --account-name  --container-name  --name  --file 

3. Using Azure PowerShell

Azure PowerShell provides cmdlets for managing Azure resources.

To list blobs in a container:

Get-AzStorageBlob -Container "" -Context (Get-AzStorageAccount -ResourceGroupName "" -Name "").Context

To download a blob:

Get-AzStorageBlobContent -Container "" -Blob "" -Destination "" -Context (Get-AzStorageAccount -ResourceGroupName "" -Name "").Context

To upload a blob:

Set-AzStorageBlobContent -Container "" -File "" -Blob "" -Context (Get-AzStorageAccount -ResourceGroupName "" -Name "").Context

4. Using Azure SDKs

Azure Storage offers client libraries for various programming languages, allowing you to programmatically access and manage blobs.

Here's a simplified example using the Python SDK to download a blob:

from azure.storage.blob import BlobServiceClient

            connect_str = ""
            blob_service_client = BlobServiceClient.from_connection_string(connect_str)

            container_client = blob_service_client.get_container_client("")
            blob_client = container_client.get_blob_client("")

            with open("", "wb") as download_file:
                download_file.write(blob_client.download_blob().readall())
            

Refer to the SDK Reference for detailed examples in your preferred language.

5. Using Shared Access Signatures (SAS)

SAS tokens provide limited access to blobs without exposing your storage account credentials. You can generate SAS tokens via the Azure portal, CLI, PowerShell, or programmatically.

Once you have a SAS token and URI, you can use it to access the blob directly:

https://.blob.core.windows.net//?

Tip:

For security best practices, always use the principle of least privilege when granting access to your blobs. Prefer SAS tokens or Azure RBAC roles over sharing account keys.

6. Direct Blob URLs

If a blob is publicly accessible, you can access it directly via its URL:

https://.blob.core.windows.net//

Note that this requires the blob to have public read access enabled.

For more advanced scenarios like managing access tiers, replication, and data lifecycle management, please refer to other sections of this documentation.