Set Container ACL (REST API)
Updated: June 12, 2012
The Set Container ACL operation sets the permissions for the specified container. The permissions indicate whether blobs in a container may be accessed publicly.
Beginning with the 2009-09-19 version, the container permissions provide the following options for managing container access:
-
Full public read access: Container and blob data can be read via anonymous request. Clients can enumerate blobs within the container via anonymous request, but cannot enumerate containers within the storage account.
-
Public read access for blobs only: Blob data within this container can be read via anonymous request, but container data is not available. Clients cannot enumerate blobs within the container via anonymous request.
-
No public read access: Container and blob data can be read by the account owner only.
Set Container ACL also sets a container-level access policy for use with Shared Access Signatures. For more information, see Use a Stored Access Policy.
All public access to the container is anonymous, as is access via a Shared Access Signature.
The Set Container ACL request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account:
| Method | Request URI | HTTP Version |
|---|---|---|
|
PUT |
|
HTTP/1.1 |
Emulated Storage Service URI
When making a request against the emulated storage service, specify the emulator hostname and Blob service port as 127.0.0.1:10000, followed by the emulated storage account name:
| Method | Request URI | HTTP Version |
|---|---|---|
|
PUT |
|
HTTP/1.1 |
For more information, see About Development Storage and Differences between Development Storage and Cloud Storage Services.
URI Parameters
The following additional parameters may be specified on the request URI.
| Parameter | Description |
|---|---|
|
timeout |
Optional. The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. |
Request Headers
The following table describes required and optional request headers.
| Request Header | Description |
|---|---|
|
Authorization |
Required. Specifies the authentication scheme, account name, and signature. For more information, see Authentication for the Windows Azure Storage Services. |
|
Date or x-ms-date |
Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authentication for the Windows Azure Storage Services. |
|
x-ms-version |
Optional. Specifies the version of the operation to use for this request. For more information, see Versioning for the Blob, Queue, and Table services in Windows Azure. |
|
x-ms-blob-public-access |
Optional. Specifies whether data in the container may be accessed publicly and the level of access. Possible values include:
If this header is not included in the request, container data is private to the account owner. |
|
x-ms-lease-id: <ID> |
Optional, version 2012-02-12 and newer. If specified, Set Container ACL only succeeds if the container's lease is active and matches this ID. If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. |
Request Body
To specify a container-level access policy, provide a unique identifier and access policy in the request body for the Set Container ACL operation.
The SignedIdentifier element includes the unique identifier, as specified in the Id element, and the details of the access policy, as specified in the AccessPolicy element. The maximum length of the unique identifier is 64 characters.
The Start and Expiry fields must be expressed as UTC times and must adhere to a valid ISO 8061 format. Supported ISO 8061 formats include the following:
-
YYYY-MM-DD
-
YYYY-MM-DDThh:mmTZD
-
YYYY-MM-DDThh:mm:ssTZD
-
YYYY-MM-DDThh:mm:ss.ffffffTZD
For the date portion of these formats, YYYY is a four-digit year representation, MM is a two-digit month representation, and DD is a two-digit day representation. For the time portion, hh is the hour representation in 24-hour notation, mm is the two-digit minute representation, ss is the two-digit second representation, and ffffff is the six-digit millisecond representation. A time designator T separates the date and time portions of the string, while a time zone designator TZD specifies a time zone.
<?xml version="1.0" encoding="utf-8"?> <SignedIdentifiers> <SignedIdentifier> <Id>unique-64-character-value</Id> <AccessPolicy> <Start>start-time</Start> <Expiry>expiry-time</Expiry> <Permission>abbreviated-permission-list</Permission> </AccessPolicy> </SignedIdentifier> </SignedIdentifiers>
Sample Request
Request Syntax:
PUT https://myaccount.blob.core.windows.net/mycontainer?restype=container&comp=acl HTTP/1.1
Request Headers:
x-ms-version: 2011-08-18
x-ms-date: Sun, 25 Sep 2011 00:42:49 GMT
x-ms-blob-public-access: container
Authorization: SharedKey myaccount:V47F2tYLS29MmHPhiR8FyiCny9zO5De3kVSF0RYQHmo=
Request Body:
<?xml version="1.0" encoding="utf-8"?>
<SignedIdentifiers>
<SignedIdentifier>
<Id>MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=</Id>
<AccessPolicy>
<Start>2009-09-28T08:49:37.0000000Z</Start>
<Expiry>2009-09-29T08:49:37.0000000Z</Expiry>
<Permission>rwd</Permission>
</AccessPolicy>
</SignedIdentifier>
</SignedIdentifiers>
The response includes an HTTP status code and a set of response headers.
Status Code
A successful operation returns status code 200 (OK).
For information about status codes, see Status and Error Codes.
Response Headers
The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.
| Response header | Description |
|---|---|
|
ETag |
The ETag for the container. If the request version is 2011-08-18 or newer, the ETag value will be in quotes. |
|
Last-Modified |
Returns the date and time the container was last modified. The date format follows RFC 1123. For more information, see Representation of Date/Time Values in Headers. Any operation that modifies the container or its properties or metadata updates the last modified time, including setting the container's permissions. Operations on blobs do not affect the last modified time of the container. |
|
x-ms-request-id |
This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations |
|
x-ms-version |
Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and later. |
|
Date |
A UTC date/time value generated by the service that indicates the time at which the response was initiated. |
Sample Response
Response Status: HTTP/1.1 200 OK Response Headers: Transfer-Encoding: chunked Date: Sun, 25 Sep 2011 22:42:55 GMT ETag: "0x8CB171613397EAB" Last-Modified: Sun, 25 Sep 2011 22:42:55 GMT x-ms-version: 2011-08-18 Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
Only the account owner may call this operation.
Only the account owner may access resources in a particular container, unless the owner has specified that container resources are available for public access by setting the permissions on the container, or has issued a Shared Access Signature for a resource within the container.
When you set permissions for a container, the existing permissions are replaced. To update the container's permissions, call Get Container ACL (REST API) to fetch all access policies associated with the container, modify the access policy that you wish to change, and then call Set Container ACL with the complete set of data to perform the update.
Enabling Anonymous Public Access on Container Data
To enable anonymous public read access on container data, call Set Container ACL with the x-ms-blob-public-access header set to container or blob. To disable anonymous access, call Set Container ACL without specifying the x-ms-blob-public-access header.
If you set x-ms-blob-public-access to blob, clients can call the following operations anonymously:
-
Get Blob (REST API)
-
Get Blob Properties (REST API)
-
Get Blob Metadata (REST API)
-
Get Block List (REST API) (for the committed block list only)
-
Get Page Ranges (REST API)
If you set x-ms-blob-public-access to container, clients can call the following operations anonymously:
-
The blob access operations listed above.
-
Get Container Properties (REST API)
-
Get Container Metadata (REST API)
-
List Blobs (REST API)
Establishing Container-Level Access Policies
A container-level access policy can specify the start time, expiry time, and permissions for the Shared Access Signatures with which it's associated. Depending on how you want to control access to your container or blob resource, you can specify all of these parameters within the container-level access policy, and omit them from the URL for the Shared Access Signature. Doing so permits you to modify the associated signature's behavior at any time, as well as to revoke it. Or you can specify one or more of the access policy parameters within the container-level access policy, and the others on the URL. Finally, you can specify all of the parameters on the URL. In this case, you can use the container-level access policy to revoke the signature, but not to modify its behavior. See specifying a Use a Stored Access Policy for more information about establishing access policies.
Together the Shared Access Signature and the container-level access policy must include all fields required to authenticate the signature. If any required fields are missing, the request will fail. Likewise, if a field is specified both in the Shared Access Signature URL and in the container-level access policy, the request will fail with status code 400 (Bad Request). See Create a Shared Access Signature for more information about the fields that comprise a Shared Access Signature.
Note that at most five separate access policies can be set for a given container at any time. If more than five access policies are passed in the request body, then the service returns status code 400 (Bad Request).
Note that a Shared Access Signature can be issued on a container or a blob regardless of whether container data is available for anonymous read access. A Shared Access Signature provides a greater measure of control over how, when, and to whom a resource is made accessible.