Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This script helps you to find the Recovery Services vault where your storage account is registered.
Sample script to find the Recovery Services vault
Param(
[Parameter(Mandatory=$True)][System.String] $ResourceGroupName,
[Parameter(Mandatory=$True)][System.String] $StorageAccountName,
[Parameter(Mandatory=$True)][System.String] $SubscriptionId
)
Connect-AzAccount -Environment AzureChinaCloud
Select-AzSubscription -Subscription $SubscriptionId
$vaults = Get-AzRecoveryServicesVault
$found = $false
foreach($vault in $vaults)
{
Write-Verbose "Checking vault: $($vault.Id)" -Verbose
$containers = Get-AzRecoveryServicesBackupContainer -ContainerType AzureStorage -FriendlyName $StorageAccountName -ResourceGroupName $ResourceGroupName -VaultId $vault.Id -Status Registered
if($containers -ne $null)
{
$found = $True
Write-Information "Found Storage account $StorageAccountName registered in vault: $($vault.Id)" -InformationAction Continue
break;
}
}
if(!$found)
{
Write-Information "Storage account: $StorageAccountName is not registered in any vault of this subscription" -InformationAction Continue
}
Execute the script to find the Recovery Services vault
To execute the script for finding the Recovery Services vault where your storage account is registered, follow these steps:
Save the preceding script on your machine with a name of your choice. In this example, we saved it as FindRegisteredStorageAccount.ps1.
Execute the script by providing the following parameters:
- -ResourceGroupName - Resource Group of the storage account
- -StorageAccountName - Storage Account Name
- -SubscriptionID - The ID of subscription where the storage account is present.
The following example tries to find the Recovery Services vault where the afsaccount storage account is registered:
.\FindRegisteredStorageAccount.ps1 -ResourceGroupName AzureFiles -StorageAccountName afsaccount -SubscriptionId aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e
Output of the script
The output shows the complete path of the Recovery Services vault where the storage account is registered. Here's a sample output:
Found Storage account afsaccount registered in vault: /subscriptions/ aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/azurefiles/providers/Microsoft.RecoveryServices/vaults/azurefilesvault123
Next steps
Learn how to Backup Azure File Shares from the Azure portal