Object Replication of Azure Blobs.
Tags: azure, beginners
Published: 2022-08-23 17:46:00

Azure Blob storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that doesn't adhere to a particular data model or definition, such as text or binary data.

**FAQ**

1. What is a Replication Rule?
A replication rule is a rule to replicate objects from a container in a storage account to another.
The rule is attached to the storage account which has different parameters, but most importantly the Destination storage account.
The rule automatically replicates the objects to the destination container whenever we upload something to the source container.

2. What do we mean by cross-region?
Cross-region here means that our containers in the storage accounts are deployed in different regions. Here I deployed a container in **us-east** but I want to the replicate the objects to another container deployed in **australia-southeast**

3. Why do we need a Replication between the storage accounts?
Mainly for Disaster Recovery (DR). Whenever the bucket hosted in our primary datacenter goes down, we can immediately and easily reroute to our secondary datacenter which can be in the same zone or some other zone/region.

------------------------------------------------------------------

## Creating my Source Storage Account and a Source Container in it.
- Create a Storage Account, name it something like 'sourcestorage-20YYMMDD'.
![source-storage-account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1cep93x32m3xsk7k6ve.png)

- Now go to the 'Containers' in the Left Pane of the Source Storage Account and select the '+ Container'.
![+container](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yh2lfb8836baphy2ctmp.png)

- Name the container and select 'Create'.
![create-container](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w039waf2xxcv1mhnegpp.png)
Container is created!
![container-created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ure0zlmikks32doxl5ba.png)

------------------------------------------------------------------

## Creating my Destination Storage Account and a Destination Container in it.
- Create another Storage Account, I named it 'destination20220823' [Note: Character length restriction while naming]
P.s. I created this Storage account in **australia-southeast** region while my source storage account was in **us-east** region.

![destination-storage-account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71fqwf18gkiwrx6t48xj.png)

- Similar to the Source container creation, create a container in the Destination storage account.
![destination-container](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3ni03ffmv04v52kjj23.png)
Destination container is created!

------------------------------------------------------------------

## Creating a Replication rule.
Now we will create a replication rule which will replicate objects from the Source container in the Storage Storage Account to the Destination container in the Destination Storage Account.

- Go to the Source Storage Account, and there proceed to Object replication option under the Data management section in the Left Pane. Then select 'Create Replication rules'
![object-replication](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k00we31zmiaqq38lt81.png)

- Now select your destination storage account and fill up the container pair details. In my case I paired my source container 'sourcecontainer-20220823' to my destination container 'destination20220823'.
![my-replication-rule](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvdq5qbq7s6te1d9oy2x.png)

- As we can see that the replication rule is successfully attached.
![replication-rule-success](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4inxvjc814cd5312pw22.png)

------------------------------------------------------------------

## Testing the Replication rule.
- Uploading a file to the source container 'sourcecontainer-20220823'
![upload-file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwt0zejrtt3j96burv2i.png)

- We can see that the file is successfully uploaded to the source container.
![file-upload-success](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqdgn95nd7mku0kntqlv.png)

- In about 2~3mins, the file is successfully replicated to the destination container.
![file-replication-success](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rxs9jtx1a69tczi4c45.png)