Loading...

Azure Storage | How to migrate Azure Queue Data from One Account to Another

Azure Storage | How to migrate Azure Queue Data from One Account to Another

Storage queues are like service bus queue, the messages are not designed to store permanent like blobs/files, once the receiver processes the messages, they would be deleted. As queues use a publisher subscriber model, and the data is transient it may be easiest to recreate the queue. Please follow the below steps to migrate Azure Queue Data from one Storage account to another storage account:

  • List all queues from the source storage account.
  • create queues with the same names in the Target Storage account.
  • Read every message from the source and write them to the destination.

Guidelines:

  1. Your client must have network access to both the source and destination storage accounts. To learn how to configure the network settings for each storage account, see Configure Azure Storage firewalls and virtual networks | Microsoft Learn
  2. Append a SAS token to REST API calls as needed.
  3. We assume process described in this blog requires user to develop an application of their own choice by leveraging azure storage client libraries as mentioned in Technical documentation | Microsoft Learn
  4. Ensure your application can access and both source and target storage accounts and configured with appropriate roles.
  5. The examples in this article assume that you've authenticated your identity by using your storage account with SAS key for making REST API calls.

 

  1. List all queues from the source storage account.

Request:

The List Queues lists all the queues in each storage account. This request may be constructed as follows. HTTPS is recommended. Replace storage account with the name of your storage account:

 

rpadi450_11-1677851021911.png

 

Response:

 

rpadi450_12-1677851021917.png

 

  1. Create queues with the same names in the Target storage account.

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

Request:

The Create Queue request may be constructed as follows. HTTPS is recommended. Replace storageaccountname with the name of your storage account:

rpadi450_13-1677851021921.png

 

Response:

The response includes an HTTP status code and a set of response headers. A successful operation returns status code 201 (Created).

rpadi450_14-1677851021925.png

      Refer to below official documentation for the details specific to response headers

  1. Read every message from the source and write them to the destination
  • Read message from Source storage account.

 

The Get Messages operation retrieves one or more messages from the front of the queue.

            Request:

The Get Messages request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account, and myqueue with the name of your queue:

            

rpadi450_15-1677851021929.png

       Response:

The response includes an HTTP status code and a set of response headers. A successful operation returns status code 200 (OK).

 

rpadi450_16-1677851021940.png

  • Write message to Target storage account.

The Put Message operation adds a new message to the back of the message queue. A visibility timeout can also be specified to make the message invisible until the visibility timeout expires. A message must be in a format that can be included in an XML request with UTF-8 encoding. The encoded message can be up to 64 KiB in size for versions 2011-08-18 and newer, or 8 KiB in size for previous versions.

Request:

The Put Message request may be constructed as follows. HTTPS is recommended. Replace storageaccount with the name of your storage account, and myqueue with the name of your queue:

rpadi450_17-1677851021944.png

 

            Request Body:

The body of the request contains the message data in the following XML format. Note that the message content must be in a format that may be encoded with UTF-8.

<QueueMessage>      <MessageText>message-content</MessageText>  </QueueMessage> 

 

Response:

The response includes an HTTP status code and a set of response headers. A successful operation returns status code 201 (Created).

 

rpadi450_18-1677851021953.png

Once the POST operation is successful, you can check if the queue/message is copied properly by visiting source and target storage account.   

Source Storage account:

rpadi450_19-1677851021960.png

 

 

Target Storage account:

 

rpadi450_20-1677851021963.png

 

  1. Upon the message is successfully written into the destination queue or PUT operation is successful. We need to delete the queue from source queue.

       The Delete Queue operation permanently deletes the specified queue.

Request:

You can construct the Delete Queue request as follows. HTTPS is recommended. Replace myaccount with the name of your storage account.

 

 

rpadi450_21-1677851021968.png

 

 Response:

A successful operation returns status code 204 (No Content). For information about status codes, see Status and error codes.

 

 

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Azure Storage - TLS 1.0 and 1.1 retirement

Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...

1 year ago

Efficient Management of Append and Page Blobs Using Azure Storage Actions

  Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...

1 year ago

[Azure AI Search] Internal Server Error when creating CMK encrypted objects

Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...

1 year ago

Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#

Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...

1 year ago

Performing simple Azure Table Storage REST API operations using curl command.

The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...

1 year ago

Bulk delete all the old jobs from the batch account

Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...

1 year ago

Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases

In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...

2 years ago

[Azure Service Bus] JMS messages getting dead-lettered

The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...

2 years ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.