Azure Blob Storage REST API Reference
This document provides a comprehensive reference for the Azure Blob Storage REST API. You can use these REST APIs to interact with Azure Blob Storage programmatically.
The Blob Storage service offers three types of resources:
- Storage Accounts: The top-level namespace for all Azure Storage services.
- Containers: Collections of blobs, analogous to a file system directory.
- Blobs: The smallest ordered set of properties and data.
Core REST Operations
The following sections detail the core operations available for managing Azure Blob Storage resources.
1. Service Operations
Operations that act on the storage account level.
List Containers
/<storage-account-name>/<container-name>
Retrieves a list of all containers within a specified storage account.
Request Parameters:
| Name | Description | Required |
|---|---|---|
comp |
Specifies the operation to perform. For listing containers, this parameter should be list. |
Yes |
prefix |
Filters the results to return only containers whose names begin with the specified prefix. | No |
include |
Specifies that deleted, unauthorized, or metadata be included in the response. | No |
Example Request:
GET https://myaccount.blob.core.windows.net?comp=list&prefix=sample HTTP/1.1 x-ms-version: 2019-02-02 Authorization: SharedKey myaccount:YhrZksfU39wXvQd8G%2F5fU0fE6X55wY%2F0gB0v1n7B52I%3D
Example Response:
<?xml version="1.0" encoding="utf-8"?><EnumerationResults ServiceEndpoint="https://myaccount.blob.core.windows.net/">
<Prefix>sample</Prefix>
<Containers>
<Container>
<Name>sample-container-1</Name>
<Properties>
<Last-Modified>Mon, 27 Jul 2009 21:37:33 GMT</Last-Modified>
<Etag>"634792090708725200"</Etag>
</Properties>
</Container>
<Container>
<Name>sample-data</Name>
<Properties>
<Last-Modified>Mon, 27 Jul 2009 21:37:33 GMT</Last-Modified>
<Etag>"634792090708725200"</Etag>
</Properties>
</Container>
</Containers>
<NextMarker />
</EnumerationResults>
Get Service Properties
/<storage-account-name>?restype=service&comp=properties
Retrieves the properties of the storage account's Blob service.
This includes settings like logging, metrics, and CORS rules.
Set Service Properties
/<storage-account-name>?restype=service&comp=properties
Configures the properties of the storage account's Blob service.
This operation allows modification of logging, metrics, and CORS configurations.
2. Container Operations
Operations that act on individual containers.
Create Container
/<storage-account-name>/<container-name>
Creates a new container within a storage account. Containers can be public or private.
Request Headers:
| Name | Description | Required |
|---|---|---|
x-ms-blob-public-access |
Specifies the public access level for the container. Valid values are blob, container, or none. |
No |
Example Request:
PUT https://myaccount.blob.core.windows.net/mycontainer HTTP/1.1 x-ms-version: 2019-02-02 x-ms-date: Tue, 28 Jul 2009 21:37:33 GMT Authorization: SharedKey myaccount:YhrZksfU39wXvQd8G%2F5fU0fE6X55wY%2F0gB0v1n7B52I%3D x-ms-blob-public-access: container
Get Container Properties
/<storage-account-name>/<container-name>
Retrieves system properties, user-defined metadata, and access permissions for the specified container.
Delete Container
/<storage-account-name>/<container-name>
Deletes the specified container and all its contents.
3. Blob Operations
Operations that act on individual blobs.
Upload Block Blob
/<storage-account-name>/<container-name>/<blob-name>
Uploads a block blob. This is the most common way to upload data to Blob Storage.
Request Headers:
| Name | Description | Required |
|---|---|---|
x-ms-blob-type |
Specifies the type of blob. For this operation, it should be BlockBlob. |
Yes |
Content-Length |
The size of the blob in bytes. | Yes |
Example Request:
PUT https://myaccount.blob.core.windows.net/mycontainer/myblob.txt HTTP/1.1 x-ms-version: 2019-02-02 x-ms-date: Tue, 28 Jul 2009 21:37:33 GMT Authorization: SharedKey myaccount:YhrZksfU39wXvQd8G%2F5fU0fE6X55wY%2F0gB0v1n7B52I%3D x-ms-blob-type: BlockBlob Content-Length: 1024 Content-Type: text/plain [Blob content here...]
Download Blob
/<storage-account-name>/<container-name>/<blob-name>
Downloads the content of a blob.
You can specify range headers to download only a portion of the blob.
Delete Blob
/<storage-account-name>/<container-name>/<blob-name>
Deletes the specified blob.
Common Headers and Parameters
Many Blob Storage REST API operations share common headers and query parameters. Here are some of the most frequently used ones:
Common Request Headers
| Name | Description |
|---|---|
x-ms-version |
Specifies the version of the Blob Storage REST API to use for the request. It's recommended to use the latest stable version. |
Authorization |
Required for authenticated requests. Typically uses SharedKey or SAS token authentication. |
x-ms-date |
The date and time of the request in RFC 1123 format. |
x-ms-copy-source |
Used for initiating a copy operation from a source blob. |
Common Query Parameters
| Name | Description |
|---|---|
comp |
Specifies the operation to perform. Varies by resource type (e.g., list, properties, metadata). |
restype |
Specifies the resource type. Common values are service, container, and blob (though blob is often implied). |
Authentication
Requests to Azure Blob Storage must be authenticated. Common authentication methods include:
- Shared Key Authentication: Uses the storage account name and its primary or secondary access key.
- Shared Access Signature (SAS) Tokens: Provides delegated access to resources for a limited time and with specific permissions.
- Azure Active Directory (Azure AD) Authentication: For more robust and integrated security scenarios.
Refer to the official Azure Storage security documentation for detailed information on each authentication method.