Jump to content

Featured Replies

Posted

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:

 

 

 

  • Ensure the URL is formed correctly as per the operation you are trying to perform.
  • The header needs to be passed and can be done using “-H” parameter.
  • Ensure you are appending/removing extra ‘?’ to the SAS token in the URLs accordingly.
  • Http verb can be GET, PUT, PATCH or DELETE as provided by the CURL specifications.

 

 

 

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:

 

800x120vv2.png.2da9b570b7d713124a0a6d1df5b3f952.png

 

 

 

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

 

 

 

800x170vv2.png.a18c2893753a5189f66e91e6a08e4ba9.png

 

 

 

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.

 

800x206vv2.png.047ecc82051884bf6b04c14e6dd980fb.png

 

 

 

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.

 

811x152vv2.png.3aeead2e6654177ecca9877bf1d0291c.png

 

 

 

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> "

 

 

 

 

 

800x164vv2.png.2031de7c7cff5bd0eae02f4a3b897282.png

 

 

 

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

 

 

 

800x128vv2.png.0a6821341fc718ec79dfc05d0d5a943e.png

 

 

 

 

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

 

 

 

793x119vv2.png.6af59c7591bff0067be60556ac4afaa5.png

 

 

 

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.

 

801x163vv2.png.1fb5c8a0db900f1516eb525449969b14.png

 

 

 

800x156vv2.png.e656c71031e884bf5a9ad764deca8c80.png

 

 

 

Hope this helps!

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...