Azure Documentation

Accessing Azure Storage Data

This section provides a comprehensive guide on how to access your data stored in Azure Storage services, including Blob, File, Table, and Queue storage. We'll cover various methods, from the Azure portal to programmatic access using SDKs and REST APIs.

1. Using the Azure Portal

The Azure portal offers a user-friendly interface to browse, upload, download, and manage your storage data. It's the simplest way to get started.

  • Navigate to your Storage Account in the Azure portal.
  • Select the desired service (e.g., Blobs, Files, Tables).
  • Browse through containers, file shares, or tables to view your data.
  • Use the provided buttons to upload, download, or perform other management tasks.

The portal is ideal for quick inspections and manual operations.

2. Using Azure Storage Explorer

Azure Storage Explorer is a free, downloadable application that enables you to easily manage your Azure Storage resources from Windows, macOS, or Linux. It provides a rich graphical interface for interacting with your storage accounts.

  • Download and install Azure Storage Explorer.
  • Connect to your Azure subscription or use a connection string/SAS URI.
  • Browse and manage your storage resources similar to the Azure portal, but with more advanced features.

Storage Explorer is excellent for developers and administrators who need a dedicated desktop tool.

3. Programmatic Access with Azure SDKs

For applications that need to interact with Azure Storage, using the official Azure SDKs is the recommended approach. SDKs are available for various programming languages.

Example: Python SDK for Blob Storage

import os from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient connection_string = os.getenv("AZURE_STORAGE_CONNECTION_STRING") container_name = "mycontainer" blob_name = "myblob.txt" local_file_name = "local_sample_file.txt" # Create a blob service client blob_service_client = BlobServiceClient.from_connection_string(connection_string) # Create a container if it doesn't exist try: container_client = blob_service_client.create_container(container_name) print(f"Container '{container_name}' created.") except Exception as e: print(f"Container '{container_name}' already exists or error: {e}") container_client = blob_service_client.get_container_client(container_name) # Create a local file to upload with open(local_file_name, "w") as f: f.write("This is a sample file for Azure Blob Storage upload.") # Upload the blob blob_client = container_client.get_blob_client(blob_name) with open(local_file_name, "rb") as data: blob_client.upload_blob(data) print(f"Blob '{blob_name}' uploaded to container '{container_name}'.") # Download the blob download_file_path = "downloaded_" + blob_name with open(download_file_path, "wb") as download_file: download_file.write(blob_client.download_blob().readall()) print(f"Blob '{blob_name}' downloaded to '{download_file_path}'.")

Refer to the official Azure SDK documentation for your preferred language (e.g., .NET, Java, Node.js, Python, Go) for detailed examples and APIs.

4. Using the Azure CLI

The Azure Command-Line Interface (CLI) provides a powerful set of commands to manage Azure resources, including Azure Storage. It's excellent for scripting and automating tasks.

Example: Azure CLI commands for Blob Storage

# List all storage accounts in a resource group az storage account list --resource-group MyResourceGroup # List blobs in a container az storage blob list --account-name mystorageaccount --container-name mycontainer --output table # Upload a blob az storage blob upload --account-name mystorageaccount --container-name mycontainer --name myblob.txt --file path/to/local/myblob.txt # Download a blob az storage blob download --account-name mystorageaccount --container-name mycontainer --name myblob.txt --file path/to/save/myblob.txt

The Azure CLI is a versatile tool for quick operations and automation.

5. Using the REST API

For maximum flexibility or when SDKs are not available, you can use the Azure Storage REST API directly. This involves making HTTP requests to the Azure Storage endpoints.

Key Operations:

  • GET requests to list resources or retrieve data.
  • PUT requests to create or update resources.
  • DELETE requests to remove resources.

Authentication is typically handled via Shared Key authorization or Shared Access Signatures (SAS).

Refer to the Azure Storage REST API documentation for detailed endpoint information and request/response formats.

Choosing the Right Method

  • Azure Portal: Best for quick checks, manual uploads/downloads, and users new to Azure.
  • Azure Storage Explorer: Great for desktop management, complex browsing, and cross-platform use.
  • Azure SDKs: Essential for integrating storage access into your applications.
  • Azure CLI: Ideal for scripting, automation, and command-line management.
  • REST API: Provides ultimate control for custom integrations and low-level operations.

Select the method that best suits your task and technical expertise.