Del via


Create Queue (Azure Storage)

The Create Queue operation creates a queue in a storage account.

Request

You can construct the Create Queue request as shown here. We recommend that you use HTTPS. Replace myaccount with the name of your storage account.

Method Request URI HTTP version
PUT https://myaccount.queue.core.windows.net/myqueue HTTP/1.1

Emulated storage service request

When you make a request against the emulated storage service, specify the emulator hostname and Azure Queue Storage port as 127.0.0.1:10001, followed by the emulated storage account name:

Method Request URI HTTP version
PUT http://127.0.0.1:10001/devstoreaccount1/myqueue HTTP/1.1

For more information, see Use the Azurite emulator for local Azure Storage development.

URI parameters

You can specify additional parameters on the request URI, as shown here.

Parameter Description
timeout Optional. The timeout parameter is expressed in seconds. For more information, see Set time-outs for Queue service operations.

Request headers

The required and optional request headers are described in the following table:

Request header Description
Authorization Required. Specifies the authorization scheme, account name, and signature. For more information, see Authorize requests to Azure Storage.
Date or x-ms-date Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authorize requests to Azure Storage.
x-ms-version Optional. Specifies the version of the operation to use for this request. For more information, see Versioning for Azure Storage services.
x-ms-meta-name:value Optional. A name-value pair to associate with the queue as metadata.

Note: As of version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers.
x-ms-client-request-id Optional. Provides a client-generated, opaque value with a 1-kibibyte (KiB) character limit that's recorded in the logs when logging is configured. We highly recommend that you use this header to correlate client-side activities with requests that the server receives. For more information, see Monitor Azure Queue Storage.

Request Body

None.

Response

The response includes an HTTP status code and a set of response headers.

Status code

A successful operation returns status code 201 (Created).

For information about status codes, see Status and error codes.

Response headers

The response for this operation includes the headers that are described in the following table. The response might also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response header Description
ms-request-id Uniquely identifies the request that was made, and you can use it to troubleshoot the request. For more information, see Troubleshoot API operations.
x-ms-version Indicates the Azure Queue Storage version that's 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 that's generated by the service and that indicates the time when the response was initiated.
x-ms-client-request-id Can be used to troubleshoot requests and corresponding responses. The value of this header is equal to the value of the x-ms-client-request-id header if it's present in the request and the value contains no more than 1024 visible ASCII characters. If the x-ms-client-request-id header isn't present in the request, it won't be present in the response.

Sample response

Response Status:  
HTTP/1.1 201 Created  
  
Response Headers:  
Transfer-Encoding: chunked  
Date: Fri, 16 Sep 2011 01:20:22 GMT  
x-ms-version: 2011-08-18  
Server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0  

Authorization

Only the account owner may call this operation.

Remarks

You can specify user-defined metadata as name-value pairs on the queue when you create it.

If a queue with the specified name already exists, Azure Queue Storage checks the metadata that's associated with the existing queue. If the existing metadata is identical to the metadata that's specified on the Create Queue request, status code 204 (No Content) is returned. If the existing metadata doesn't match the metadata provided with the Create Queue request, the operation fails and status code 409 (Conflict) is returned. Clients can take advantage of this behavior to avoid an additional call to check to see whether a named queue already exists.

For guidance about valid queue names, see Name queues and metadata. If the specified queue name isn't a valid name, the Create Queue operation returns status code 400 (Bad Request), along with additional error information, as shown in the following example:

HTTP/1.1 400 One of the request inputs is out of range.  
Connection: Keep-Alive  
Content-Length: 226  
Via: 1.1 TK5-PRXY-22  
Date: Wed, 02 May 2012 17:47:54 GMT  
Content-Type: application/xml  
Server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0  
x-ms-request-id: fda2babe-ffbb-4f0e-a11b-2bfbd871ba9f  
x-ms-version: 2011-08-18  
  
<?xml version="1.0" encoding="utf-8"?>  
<Error>  
   <Code>OutOfRangeInput</Code>  
   <Message>One of the request inputs is out of range.  
   RequestId:fda2babe-ffbb-4f0e-a11b-2bfbd871ba9f  
   Time:2012-05-02T17:47:55.4334169Z</Message>  
</Error>  

See also

Azure Queue error codes
Authorize requests to Azure Storage
Status and error codes