<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saswat Sambit</title>
    <description>The latest articles on DEV Community by Saswat Sambit (@thisissaswat).</description>
    <link>https://dev.to/thisissaswat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F904254%2Ff62cf786-86ee-4695-9111-83e48696affe.jpeg</url>
      <title>DEV Community: Saswat Sambit</title>
      <link>https://dev.to/thisissaswat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thisissaswat"/>
    <language>en</language>
    <item>
      <title>Object Replication of Azure Blobs.</title>
      <dc:creator>Saswat Sambit</dc:creator>
      <pubDate>Tue, 23 Aug 2022 17:46:00 +0000</pubDate>
      <link>https://dev.to/thisissaswat/object-replication-of-azure-blobs-34kd</link>
      <guid>https://dev.to/thisissaswat/object-replication-of-azure-blobs-34kd</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FAQ&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What is a Replication Rule?&lt;br&gt;
A replication rule is a rule to replicate objects from a container in a storage account to another.&lt;br&gt;
The rule is attached to the storage account which has different parameters, but most importantly the Destination storage account.&lt;br&gt;
The rule automatically replicates the objects to the destination container whenever we upload something to the source container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What do we mean by cross-region?&lt;br&gt;
Cross-region here means that our containers in the storage accounts are deployed in different regions. Here I deployed a container in &lt;strong&gt;us-east&lt;/strong&gt; but I want to the replicate the objects to another container deployed in &lt;strong&gt;australia-southeast&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why do we need a Replication between the storage accounts?&lt;br&gt;
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.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Creating my Source Storage Account and a Source Container in it.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a Storage Account, name it something like 'sourcestorage-20YYMMDD'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wFR3ID6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1cep93x32m3xsk7k6ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wFR3ID6J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1cep93x32m3xsk7k6ve.png" alt="source-storage-account" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now go to the 'Containers' in the Left Pane of the Source Storage Account and select the '+ Container'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oyyCqKWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yh2lfb8836baphy2ctmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oyyCqKWj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yh2lfb8836baphy2ctmp.png" alt="+container" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Name the container and select 'Create'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J-WmoVTg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w039waf2xxcv1mhnegpp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J-WmoVTg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w039waf2xxcv1mhnegpp.png" alt="create-container" width="880" height="470"&gt;&lt;/a&gt;&lt;br&gt;
Container is created!&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--41sjs5Dn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ure0zlmikks32doxl5ba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--41sjs5Dn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ure0zlmikks32doxl5ba.png" alt="container-created" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Creating my Destination Storage Account and a Destination Container in it.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create another Storage Account, I named it 'destination20220823' [Note: Character length restriction while naming]
P.s. I created this Storage account in &lt;strong&gt;australia-southeast&lt;/strong&gt; region while my source storage account was in &lt;strong&gt;us-east&lt;/strong&gt; region.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6tSNn5yj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71fqwf18gkiwrx6t48xj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6tSNn5yj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71fqwf18gkiwrx6t48xj.png" alt="destination-storage-account" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Similar to the Source container creation, create a container in the Destination storage account.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RRvs5fSm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i3ni03ffmv04v52kjj23.png" alt="destination-container" width="880" height="470"&gt;
Destination container is created!&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Creating a Replication rule.
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;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'&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aA2Pllj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k00we31zmiaqq38lt81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aA2Pllj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k00we31zmiaqq38lt81.png" alt="object-replication" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;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'.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--baNCpzlY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvdq5qbq7s6te1d9oy2x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--baNCpzlY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvdq5qbq7s6te1d9oy2x.png" alt="my-replication-rule" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As we can see that the replication rule is successfully attached.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1ZS4HCXa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4inxvjc814cd5312pw22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1ZS4HCXa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4inxvjc814cd5312pw22.png" alt="replication-rule-success" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Testing the Replication rule.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Uploading a file to the source container 'sourcecontainer-20220823'&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NyMxqQym--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwt0zejrtt3j96burv2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NyMxqQym--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwt0zejrtt3j96burv2i.png" alt="upload-file" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can see that the file is successfully uploaded to the source container.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mi9sZ8bV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqdgn95nd7mku0kntqlv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mi9sZ8bV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqdgn95nd7mku0kntqlv.png" alt="file-upload-success" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In about 2~3mins, the file is successfully replicated to the destination container.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7ruekQnc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rxs9jtx1a69tczi4c45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ruekQnc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rxs9jtx1a69tczi4c45.png" alt="file-replication-success" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Overview of Azure Storage Accounts and their Redundancy.</title>
      <dc:creator>Saswat Sambit</dc:creator>
      <pubDate>Tue, 23 Aug 2022 16:30:00 +0000</pubDate>
      <link>https://dev.to/thisissaswat/overview-of-azure-storage-accounts-and-their-redundancy-54mo</link>
      <guid>https://dev.to/thisissaswat/overview-of-azure-storage-accounts-and-their-redundancy-54mo</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclaimer&lt;/em&gt;: Learning about Azure Storage Accounts is very ambiguous and overwhelming &amp;amp; quite confusing when coming straight from AWS storage services. (Personal Experience 😬)&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an Azure Storage Account?
&lt;/h2&gt;

&lt;p&gt;An Azure storage account contains all of your Azure Storage data objects, including blobs, file shares, queues, tables, and disks. The storage account provides a unique namespace for your Azure Storage data that's accessible from anywhere in the world over HTTP or HTTPS.&lt;/p&gt;

&lt;p&gt;Types of Storage Account provided and recommended by Microsoft for most scenarios,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bG152uzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8orc9m4qf81v9df7h9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bG152uzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8orc9m4qf81v9df7h9j.png" alt="types-of-storage-account-table" width="880" height="696"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are some Legacy storage accounts which aren’t recommended by Microsoft, but may be used in certain scenarios:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JKCLBbL3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctjsvf2c1wo7olyn6fe9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JKCLBbL3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctjsvf2c1wo7olyn6fe9.png" alt="legacy-storage-accounts" width="880" height="762"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How is Storage in Azure any different from that of AWS?
&lt;/h2&gt;

&lt;p&gt;In AWS platform, storage is primarily broken down into 3 services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simple Storage Service (S3)&lt;/strong&gt; - Basic object storage that makes data available through an Internet accessible API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elastic Block Storage (EBS)&lt;/strong&gt; - Block level storage intended for access by a single VM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elastic File System (EFS)&lt;/strong&gt; - File storage meant for use as shared storage for up to thousands of EC2 instances.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Azure Storage, subscription-bound storage accounts allow you to create and manage the following storage services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Blob storage&lt;/strong&gt; stores any type of text or binary data, such as a document, media file, or application installer. You can set Blob storage for private access or share contents publicly to the Internet. Blob storage serves the same purpose as both AWS S3 and EBS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Table storage&lt;/strong&gt; stores structured datasets. Table storage is a NoSQL key-attribute data store that allows for rapid development and fast access to large quantities of data. Similar to AWS' SimpleDB and DynamoDB services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Queue storage&lt;/strong&gt; provides messaging for workflow processing and for communication between components of cloud services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;File storage&lt;/strong&gt; offers shared storage for legacy applications using the standard server message block (SMB) protocol. File storage is used in a similar manner to EFS in the AWS platform.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a table briefly comparing AWS &amp;amp; Azure storage services,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uuW3t6ay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/242tepio7cu3hlhuu8qv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uuW3t6ay--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/242tepio7cu3hlhuu8qv.png" alt="azure-aws-comparison-1" width="880" height="910"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now here I've created a Storage Account where I can store blobs,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--izWAviU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/db3r7gcv4y58vmn8jgto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--izWAviU3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/db3r7gcv4y58vmn8jgto.png" alt="storage-account-desc" width="880" height="470"&gt;&lt;/a&gt;&lt;br&gt;
As we can see in the above image, file service along Queue &amp;amp; Table services are disabled in this account.&lt;br&gt;
Note: I can store blobs (in Containers), files, queue or tables by accessing the respective option under the Data Storage section in the Left Pane.&lt;/p&gt;

&lt;p&gt;Now I created another Storage Account where both Blob and File Service are enabled,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yIi-d4J6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ueucm8i9i3mhphixwcjl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yIi-d4J6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ueucm8i9i3mhphixwcjl.png" alt="file-service-enabled" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Redundancy of Storage Accounts
&lt;/h2&gt;

&lt;p&gt;Azure Storage always stores multiple copies of your data so that it's protected from planned and unplanned events, including transient hardware failures, network or power outages, and massive natural disasters. Redundancy ensures that your storage account meets its availability and durability targets even in the face of failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Redundancy in the primary region.
&lt;/h2&gt;

&lt;p&gt;Data in an Azure Storage account is always replicated three times in the primary region. Azure Storage offers two options for how your data is replicated in the primary region:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Locally redundant storage (LRS) copies your data synchronously three times within a single physical location in the primary region. LRS is the least expensive replication option, but isn't recommended for applications requiring high availability or durability.&lt;/li&gt;
&lt;li&gt;Zone-redundant storage (ZRS) copies your data synchronously across three Azure availability zones in the primary region. For applications requiring high availability, Microsoft recommends using ZRS in the primary region, and also replicating to a secondary region.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Redundancy in a secondary region.
&lt;/h2&gt;

&lt;p&gt;For applications requiring high durability, you can choose to additionally copy the data in your storage account to a secondary region that is hundreds of miles away from the primary region. If your storage account is copied to a secondary region, then your data is durable even in the case of a complete regional outage or a disaster in which the primary region isn't recoverable.&lt;/p&gt;

&lt;p&gt;Azure Storage offers two options for copying your data to a secondary region:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Geo-redundant storage (GRS) copies your data synchronously three times within a single physical location in the primary region using LRS. It then copies your data asynchronously to a single physical location in the secondary region. Within the secondary region, your data is copied synchronously three times using LRS.&lt;/li&gt;
&lt;li&gt;Geo-zone-redundant storage (GZRS) copies your data synchronously across three Azure availability zones in the primary region using ZRS. It then copies your data asynchronously to a single physical location in the secondary region. Within the secondary region, your data is copied synchronously three times using LRS.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: We can set up the Redundancy while creating a Storage Account -or- we can change it after creating an account acc. to our requirements.&lt;/p&gt;




&lt;h2&gt;
  
  
  Changing the Redundancy replication of a Storage Account from LRS to GRS
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;As we can see the in the details of the Storage Account, that it is set for LRS replication. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UGn9wwyD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2l8fr37udw8oiyz9xcbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UGn9wwyD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2l8fr37udw8oiyz9xcbo.png" alt="storage-account-deployed" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proceed for Configuration in Left Pane of the Storage Account and there change it to GRS in Replication option and save it.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aZlLavtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rs4hwxl2fhuwcinxll07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aZlLavtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rs4hwxl2fhuwcinxll07.png" alt="select-grs" width="880" height="470"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UcgrZglt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20f6x6vf8qjz0gqswvqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UcgrZglt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20f6x6vf8qjz0gqswvqn.png" alt="config-saved" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we can see that our Storage Account is set for GRS replication.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xfaJbX_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx4cnfl3e2zjsoulg21m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xfaJbX_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx4cnfl3e2zjsoulg21m.png" alt="grs-deployed" width="880" height="470"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CrGQnKOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc5yvlpu0kz0futr7zp6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CrGQnKOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc5yvlpu0kz0futr7zp6.png" alt="overview-after-grs-deployed" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>azure</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Setting up a Cross-Region Replication rule for S3 buckets through AWS CLI.</title>
      <dc:creator>Saswat Sambit</dc:creator>
      <pubDate>Sat, 06 Aug 2022 13:06:00 +0000</pubDate>
      <link>https://dev.to/thisissaswat/setting-up-a-cross-region-replication-rule-for-s3-buckets-through-aws-cli-54jn</link>
      <guid>https://dev.to/thisissaswat/setting-up-a-cross-region-replication-rule-for-s3-buckets-through-aws-cli-54jn</guid>
      <description>&lt;p&gt;S3 is an object-storage service provided by AWS. Object storage takes each piece of data and designates it as an object. Data is kept in separate storehouses versus files in folders and is bundled with associated metadata and a unique identifier to form a storage pool.&lt;/p&gt;

&lt;p&gt;This S3 object-based storage is accessible via a Web API which makes it easy to use, against a block-storage type like EBS which has to be attached to an EC2 Instance in order to access it.&lt;/p&gt;

&lt;p&gt;You don't have to pay for creating a S3 bucket but you have pay for the Objects! That means every file uploaded to the bucket as well as for how long decides your bill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FAQ&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What is a Replication Rule?&lt;br&gt;
A replication rule is a rule to replicate objects from a bucket to another.&lt;br&gt;
The rule is attached to a particular bucket (aka Source bucket) which has different parameters, but most importantly the Destination bucket.&lt;br&gt;
The rule automatically replicates the objects to the destination bucket whenever we upload something to the source bucket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What do we mean by cross-region?&lt;br&gt;
Cross-region here means that our buckets are deployed in different regions. For e.g. I deployed a bucket in &lt;strong&gt;us-west-1&lt;/strong&gt; (N. California) but I want to the replicate the objects to another bucket deployed in &lt;strong&gt;ap-northeast-1&lt;/strong&gt; (Tokyo)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Why do we need a Replication between the buckets?&lt;br&gt;
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.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So let's start setting up our Replication rule on a bucket!&lt;/p&gt;

&lt;p&gt;But before using the CLI, we have to configure it. For the configuration we have to create a &lt;strong&gt;access key&lt;/strong&gt; in our AWS acc.&lt;br&gt;
&lt;code&gt;aws configure&lt;/code&gt; is the command.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jbd-iTWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p31dzw6wcdmmphf4gxmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbd-iTWr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p31dzw6wcdmmphf4gxmw.png" alt="aws configure" width="880" height="485"&gt;&lt;/a&gt;&lt;br&gt;
Here we gave the access key id and the secret access key obtained from the 'access key' we created.&lt;br&gt;
I took &lt;strong&gt;us-west-1&lt;/strong&gt; as my main region and the output format is &lt;strong&gt;json&lt;/strong&gt; which is the default one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating Source and Destination buckets in the CLI
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Let's create a source bucket and enable versioning in it.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--64GpFNKZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3sw9uoqyqxj7wwp6lid.png" alt="source-bucket" width="880" height="485"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create bucket command -&amp;gt; &lt;code&gt;aws s3api create-bucket --bucket &amp;lt;source-bucket-name&amp;gt; --region &amp;lt;region-code&amp;gt; --create-bucket-configuration LocationConstraint=&amp;lt;region-code&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: When deploying a S3 bucket in &lt;strong&gt;us-east-1&lt;/strong&gt; region, we don't have to give the &lt;code&gt;LocationConstraint&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Enable Versioning command -&amp;gt; &lt;code&gt;aws s3api put-bucket-versioning --bucket &amp;lt;source-bucket-name&amp;gt; --versioning-configuration Status=Enabled&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now let's create a destination bucket in another region and enable versioning in it.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qQBRqCYi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/co05pyyuiugn1mizhci2.png" alt="destination-bucket" width="880" height="485"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create bucket command -&amp;gt; &lt;code&gt;aws s3api create-bucket --bucket &amp;lt;destination-bucket-name&amp;gt; --region us-east-1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: Since we deployed this destination bucket in the &lt;strong&gt;us-east-1&lt;/strong&gt; region, you can see that we don't have to use the LocationConstraint tag.&lt;/p&gt;

&lt;p&gt;Enable Versioning command -&amp;gt; &lt;code&gt;aws s3api put-bucket-versioning --bucket &amp;lt;destination-bucket-name&amp;gt; --versioning-configuration Status=Enabled&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Ok, we can see that our source and destination buckets are deployed in different regions...&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0pa2QEsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s6h8yje6nfsoziauubm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0pa2QEsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5s6h8yje6nfsoziauubm.png" alt="bucket-deployements" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Creating an IAM role and Replication Rule
&lt;/h2&gt;

&lt;p&gt;In order to create a Replication rule, we need an IAM role to attach the rule to the source bucket. For creating an IAM role, we need 2 JSON files. First for the trust-policy and the Second for the role-permissions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "s3.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save this code as &lt;strong&gt;s3-trust-policy.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then use the following command to create an IAM role and attach the trust-policy to it,&lt;br&gt;
&lt;code&gt;aws iam create-role --role-name S3replicationRole --assume-role-policy-document file://s3-trust-policy.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FzmCKvR6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a661le31xk1yz4kp7x38.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FzmCKvR6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a661le31xk1yz4kp7x38.png" alt="s3ReplicationIAMRole" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: Save the json files in the directory where you've launched your CMD else you have to properly give the file location.&lt;/p&gt;

&lt;p&gt;Now attach a Role Permission to the IAM role,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObjectVersionForReplication",
        "s3:GetObjectVersionAcl",
        "s3:GetObjectVersionTagging"
      ],
      "Resource": ["arn:aws:s3:::&amp;lt;source-bucket-name&amp;gt;/*"] 
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:GetReplicationConfiguration"],
      "Resource": ["arn:aws:s3:::source-bucket"]
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:ReplicateObject",
        "s3:ReplicateDelete",
        "s3:ReplicateTags"
      ],
      "Resource": "arn:aws:s3:::&amp;lt;destination-bucket-name&amp;gt;/*" 
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace  and  with your respective source and destination bucket names and save it as &lt;strong&gt;s3-role-perms.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now attach the file to the role with the following command,&lt;br&gt;
&lt;code&gt;aws iam put-role-policy --role-name S3replicationRole --policy-document file://s3-role-perms.json --policy-name S3replicationRolePolicy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ailyS93d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65nchrolr68u4iuagk89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ailyS93d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65nchrolr68u4iuagk89.png" alt="S3replicationRolePolicy" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Now let's create a Replication Config file which will set the Replication Rule to our Source bucket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "Role": "&amp;lt;Role-ARN&amp;gt;",
  "Rules": [
    {
      "Status": "Enabled",
      "Priority": 1,
      "DeleteMarkerReplication": { "Status": "Disabled" },
      "Filter": { "Prefix": "Documents" },
      "Destination": {
        "Bucket": "arn:aws:s3:::&amp;lt;destination-bucket-name&amp;gt;"
      }
    }
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace  with the ARN (Amazon Resource Number) of the IAM Role we created in the previous steps ...&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WvJ6oJx6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8hbfmaa8m1b6odhwngp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WvJ6oJx6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8hbfmaa8m1b6odhwngp.png" alt="Role-ARN" width="880" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;... and  with the name of the Destination bucket &amp;amp; save the file as &lt;strong&gt;replicationConf.json&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then with the help of the following command, attach this config file to the source bucket to set up the Replication Rule,&lt;br&gt;
&lt;code&gt;aws s3api put-bucket-replication --replication-configuration file://replicationConf.json --bucket &amp;lt;source-bucket-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TxfwlU3b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrimj2qp17ng1zhpxtw4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TxfwlU3b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrimj2qp17ng1zhpxtw4.png" alt="Replication Rule" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Let us verify whether the Replication Rule is properly attached or not!&lt;/p&gt;

&lt;p&gt;Use the command to check in the CLI,&lt;br&gt;
&lt;code&gt;aws s3api get-bucket-replication --bucket &amp;lt;source-bucket-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fLvVyUA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9inw591eee65bvr92szo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fLvVyUA4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9inw591eee65bvr92szo.png" alt="CLI-verify" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or we can check in the console,&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kuuMNgbx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bblo8ytrxmtrdsw3nfy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kuuMNgbx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bblo8ytrxmtrdsw3nfy.png" alt="Console-verify" width="880" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>s3</category>
    </item>
  </channel>
</rss>
