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:
- 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
- Append a SAS token to REST API calls as needed.
- 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
- Ensure your application can access and both source and target storage accounts and configured with appropriate roles.
- 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.
- 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:
Response:
- 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:
Response:
The response includes an HTTP status code and a set of response headers. A successful operation returns status code 201 (Created).
Refer to below official documentation for the details specific to response headers
- 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:
Response:
The response includes an HTTP status code and a set of response headers. A successful operation returns status code 200 (OK).
- 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:
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).
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:
Target Storage account:
- 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.
Response:
A successful operation returns status code 204 (No Content). For information about status codes, see Status and error codes.
Published on:
Learn moreRelated 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...
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...
[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...
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 ...
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 ...
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...
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...
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...
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...
[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...