Storage Account Failover (Preview) in Storage Account - Azure

This Storage account fail-over is in pre-view but i feel its wonderful feature that would help in Disaster Recovery and Migration as well. Hope this feature would be in GA & in this post we would be discussing about this feature in respect of the Migration or moving VM's , snapshot , disk in other region. Well the best way of moving or migrating Azure VM from one region to other is ASR , we all know that but incase we need to move without ASR or somehow we cant use ASR then this feature would be handy.


Lets Understand it first then will try to register the provider and perform the fail-over :


Customer managed account fail-over enables you to fail your entire storage account over to the secondary region.

When you force failover to the secondary region, Clients can begin writing data to the secondary endpoint once failover is complete.

Failover typically takes about an Hour.

Storage account with GRS and RA-GRS are entitled for this feature thats quite obvious but once you fail-over to the secondary region, the storage account is configured to be LRS & you can make it GRS or RA-GRS.

Data replicated from Primary account to secondary is always asynchronous hence there is always delay before a write to the primary region is replicated to secondary region.

When you force failover the , all data in primary region is lost as the secondary region becomes the new primary region & configured as LRS.

Last Sync Time property indicates the most recent time that data replicated from primary to secondary region. Any data write after last sync would be lost.


First register the provider if not already to utilize this preview feature and once you run the below command it takes days to get register.

Register-AzProviderFeature -FeatureName customercontrolledfailover -ProviderNamespace Microsoft.Storage


Below command would help you check if provider is registered already

Get-AzProviderFeature -FeatureName CustomerControlledFailover -ProviderNamespace Microsoft.Storage




Created the storage account with GRS redundancy :-





Optional# lets copy the managed snapshot to this storage account so that we could fail-over and check if we could create the VM out of that disk.

$resourceGroupName = 'RG'
$snapshotName = 'snapshotname'
$resourceGroupNameStorageAccount = 'RG'
$storageAccountName = 'storageaccountname'
$storageContainerName = 'containername'
$destinationVHDFileName = 'vhdfilename'

$storageAccountKey = Get-AzStorageAccountKey -resourceGroupName $resourceGroupNameStorageAccount -AccountName $storageAccountName

$sas = Grant-AzSnapshotAccess -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName  -DurationInSecond 9600 -Access Read

$destinationContext = New-AzStorageContext –storageAccountName $storageAccountName -StorageAccountKey ($storageAccountKey).Value[0]

Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $storageContainerName -DestContext $destinationContext -DestBlob $destinationVHDFileName


This command would give the status of the copy :-

Get-AzStorageBlobCopystate -Context $destinationContext -Blob $destinationVHDFileName -Container $storageContainerName


Once copy is success , lets force fail-over and try to create the VM out of it. Once you hit the button prepare for fail-over, it would show you last sync time and ask for confirmation.





Hit the failover button and after a short while your secondary region would become primary and primary would become unavailable and so is the data on primary region so be very cautious while performing this.




Well incase of primary unavailable , MS fail-over by itself or you can do by force but if you do that by force as discussed above , you will loose all data inside the primary and your secondary will become primary - what you can do , you can copy data from secondary region to some-other region and perform your task.






No comments:

Post a Comment

MS Defenders

 Microsoft Defender offers a wide range of security solutions, similar to the ones we've discussed (Defender for Containers, Defender fo...