Issue In Azure Restore – Restore-AzRecoveryServicesBackupItem : Set vault context first using cmdlet Set-AzRecoveryServicesVaultContext

Hello Friends,
Hope you all are doing good !!! 🙂 .
In our previous articles we have discussed How To Address One Issue We Faced During Enabling The BackUp . Today in this article we will talk about another issue we come across during restore file share from backup and how we fixed that issue.
Tool Installation Articles :
- Configure Azure Command Line Interface ( Azure CLI) On Windows
- Configure PowerShell For Microsoft Azure Az Module On Windows
Previous Azure series :
- Learn Basics Of Azure Networking In 60 Hours
- Learn Basic Of Azure Active Directory And Azure Identity And Access Management
- Azure DevOps – Learn at one place
If you have missed our previous articles on Azure Storage and Database Series, please check it in following links.
Part 1 – Overview Of Azure Storage and Database
Part 2 – Azure Storage Account
Part 4 – Work With Azure Blob Storage
Part 5 – Storage Explorer For Azure Storage
Part 6 – Azure Blob Storage – Snapshot Using Storage Explorer
Part 7 – Azure Blob Storage – Shared Access Signature (SAS)
Part 8 – Secure Azure Storage Using Stored Access Policy
Part 9 – Secure Azure Storage Using RBAC
Part 10 – Configure Stored Access Policy Using PowerShell
Part 11 – Get Shared Access Signature (SAS) Using PowerShell
Part 12 – Azure Blob Storage – Host Static Website In Azure Storage Account
Part 13 – Azure Blob Storage – Work With AzCopy Tool
Part 14 – Azure File Service – Overview
Part 15 – Azure File Service – Mount File Share On Window Server Using PowerShell
Part 16 – Azure File Service – Mount File Share On Window Server Using File Share URL
Part 17 – Azure File Service – Create File Share Using Power Shell
Part 18 – Azure File Service – Upload And Copy Files In File Share Using Power Shell
Part 19 – Azure File Service – BackUp And Restore Azure Files From Recovery Services Vault
Part 20 – Azure File Service – BackUp And Restore Azure Files From The File Share Pane
Part 21 – Azure File Service – Create And Manage File Share Snapshots Using PowerShell
Part 23 – Azure File Service – Restore Azure Files From Back Up Using PowerShell
Part 24 – Azure File Service – Storage Sync Service
Part 25 – Azure File Service – Storage Sync Service – Configure Azure File Sync – 1
Part 26 – Azure File Service – Storage Sync Service – Configure Azure File Sync – 2
Part 27 – Difference Between Azure Blog Storage And Azure File Storage
Part 28 – Azure Queue Storage – Overview
Part 29 – Azure Queue Storage – Store And Process Messages In Azure Queue
Issue Details :
In one of my previous article, I am working on an exercise, where I had to restore my file share from the backup using powershell. I have gather all recovery point and then tried to restore the backup using following PowerShell command.
Restore-AzRecoveryServicesBackupItem -RecoveryPoint $ManasRecoveryPoint[0] -ResolveConflict Overwrite
but it ends with the and error. Below is the error details.
Restore-AzRecoveryServicesBackupItem : Set vault context first using cmdlet Set-AzRecoveryServicesVaultContext
At line:1 char:1Restore-AzRecoveryServicesBackupItem -RecoveryPoint $ManasRecoveryPoi …~~~~~~~~~~~~~~~~~CategoryInfo : InvalidArgument: (:) [Restore-AzRecoveryServicesBackupItem], ArgumentException
FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.RestoreAzureRmRecoveryServicesBackupItem

Solution Details
As it suggested, we have to set the context of our vault, when we get it as showing in the following example.
$ManasVault = Get-AzRecoveryServicesVault -ResourceGroupName "StorageAndDatabase" -Name "Manas-Storage-RSV-PS"
Set-AzRecoveryServicesVaultContext -Vault $ManasVault
I just skipped it because some where in one Microsoft document, it mentioned that, the Set-AzRecoveryServicesVaultContext
command is going to be deprecated soon. I re-executed the command after set the context of the vault and this time it ends with restoring my file share as showing in the following figure.

This is a very small post but I hope this is informative to you. Please let me know if I missed anything important or if my understanding is not up to the mark. Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.
If you have any suggestion / feedback / doubt, you are most welcome. Stay tuned on Knowledge-Junction, will come up with more such articles.
Thanks for reading 🙂 .
1 Response
[…] Issue In Azure Restore – Restore-AzRecoveryServicesBackupItem : Set vault context first using cmdlet Set-AzRecoveryServicesVaultContext […]