The blog points to performing simple Queue REST API operations such as List, Create, Get, Put and Delete using CURL utility.
Let’s look at some of the CURL command syntax to perform REST API operations and will be making use of SAS as the auth scheme for most of the operations. We need to take care of the pointers below while performing the operations via CURL:
List Queues
List Queues (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" https://<StorageAccountName>.queue.core.windows.net?comp=list&SASToken
In the below snippet, the operation is being performed on the account and it lists the queues present inside it as below:
Create Queue
Create Queue (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" -H “Content-Length: 0” https://<StorageAccountName>.queue.core.windows.net/<QueueName>?SASToken
In the above sample, we also need to pass Content-Length as 0 to test the same via CURL and create a queue name testqueue7. You can verify from the portal further as well.
Delete Queue
Delete Queue (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" https://<StorageAccountName>.queue.core.windows.net/<QueueName>?SASToken
In the below sample, we delete a queue name testqueue6 successfully. You can verify from the portal further as well.
Put Message
Put Message (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" -H "Content-Length: <Length of Message>" -H "Content-Type: text/plain" "https://<StorageAccountName>.queue.core.windows.net/<QueueName>/messages?visibilitytimeout=XX&messagettl=XX&SASToken --data "<QueueMessage><MessageText>Message Text</MessageText></QueueMessage> "
Get Message
Get Messages (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" https://<StorageAccountName>.queue.core.windows.net/<QueueName>/messages?SASToken
Delete Message
Delete Message (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" https://<StorageAccountName>.queue.core.windows.net/<QueueName>/messages/<messageID>? popreceipt=string-value&SASToken
Clear Queue
Clear Messages (REST API) - Azure Storage | Microsoft Learn
Syntax:
curl -i -X <HTTP Verb> -H "x-ms-version: 2019-12-12" https://<StorageAccountName>.queue.core.windows.net/<QueueName>?SASToken
In the below sample, we initially added 2 messages to the queue testqueue7 and then performed clear queue operation which deleted all the messages from the queue successfully.
Hope this helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.