Introduction to Azure Storage Blobs REST API
The Azure Storage Blobs REST API allows you to interact with Azure Blob Storage programmatically. Blob Storage is a cloud object storage solution designed for storing massive amounts of unstructured data. This API provides operations for managing containers, blobs, and their properties.
Each request to Azure Storage is authenticated, and operations are performed within the context of an Azure subscription and a storage account.
Authentication
All requests to Azure Storage must be authenticated. The primary methods for authentication are:
- Shared Key Authentication: Uses the storage account's access keys.
- Shared Access Signatures (SAS): Provides delegated access to resources with defined permissions and expiry times.
- Azure Active Directory (Azure AD): For more robust and managed access control.
The following examples assume Shared Key authentication for simplicity, but the same endpoints can be used with other authentication mechanisms.
Container Operations
Manage containers within your Azure Blob Storage account.
Create Container
PUT /\{accountName\}/\{containerName\}Creates a new container in the specified storage account.
Query Parameters
Request Headers
Success Response (201 Created)
Indicates that the container was successfully created.
Error Responses
400 Bad Request: The request was malformed.
403 Forbidden: The caller does not have permission to perform this operation.
404 Not Found: The storage account or container does not exist.
Get Container Properties
GET /\{accountName\}/\{containerName\}Retrieves system properties for the specified container.
Query Parameters
Request Headers
Success Response (200 OK)
Returns container properties such as ETag, Last-Modified, Lease Status, Public Access, and Container Name.
Error Responses
403 Forbidden: The caller does not have permission to perform this operation.
404 Not Found: The storage account or container does not exist.
List Containers
GET /\{accountName\}/Lists all containers in the specified storage account.
Query Parameters
Request Headers
Success Response (200 OK)
Returns a list of containers with their properties. Includes a NextMarker if there are more results.
Error Responses
403 Forbidden: The caller does not have permission to perform this operation.
404 Not Found: The storage account does not exist.
Blob Operations
Manage blobs (block blobs, append blobs, page blobs) within containers.
Put Blob (Block Blob)
PUT /\{accountName\}/\{containerName\}/\{blobName\}Uploads a new block blob or replaces an existing block blob.
Query Parameters
comp=block.
Request Headers
Success Response (201 Created)
Indicates that the blob was successfully created or updated.
Error Responses
400 Bad Request: Invalid request parameters or body.
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
Get Blob
GET /\{accountName\}/\{containerName\}/\{blobName\}Retrieves a blob from the specified container.
Query Parameters
Request Headers
Success Response (200 OK)
Returns the blob's content and system properties.
Error Responses
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
412 Precondition Failed: A specified condition, such as If-Match or If-Modified-Since, was not met.
Delete Blob
DELETE /\{accountName\}/\{containerName\}/\{blobName\}Deletes a blob from the specified container.
Query Parameters
Request Headers
Success Response (200 OK)
Indicates that the blob was successfully deleted.
Error Responses
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
409 Conflict: The blob is currently leased.
Lease Operations
Manage leases for blobs and containers to provide exclusive write or delete access.
Acquire Lease
PUT /\{accountName\}/\{containerName\}/\{blobName\}Acquires a new lease on a blob or container.
Query Parameters
Request Headers
Success Response (201 Created)
Indicates that the lease was successfully acquired. Returns the Lease ID.
Error Responses
400 Bad Request: Invalid lease duration or other parameters.
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
Snapshot Operations
Create read-only snapshots of blobs.
Create Snapshot
PUT /\{accountName\}/\{containerName\}/\{blobName\}Creates a read-only snapshot of a blob.
Query Parameters
Request Headers
Success Response (201 Created)
Indicates that the snapshot was successfully created. Returns the ETag and Last-Modified properties of the snapshot.
Error Responses
400 Bad Request: Invalid parameters.
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
Access Tier Operations
Manage access tiers for blobs (e.g., Hot, Cool, Archive).
Set Blob Tier
PUT /\{accountName\}/\{containerName\}/\{blobName\}Sets the access tier for a blob.
Query Parameters
Request Headers
Success Response (200 OK)
Indicates that the tier was successfully set.
Error Responses
400 Bad Request: Invalid tier or other parameters.
403 Forbidden: Access denied.
404 Not Found: Container or blob not found.
409 Conflict: Blob is leased or has snapshots.