2

In the REST API for Azure Site Recovery Services located here: Get a list of replication protected items in Azure Site Recovery there are two pieces of information about the ASR vault which I am not able to find. These are needed as part of the GET Request's URL. The documentation just repeats the name and does not mention how to fetch this information. These two items are:

  1. Replication Fabric Name
  2. Replication Protection Container Name

Do you know what these are and where I can find these? The description is not very clear for these.

I have downloaded and checked the Vault Settings file as well without any success.Any pointers will be helpful.

Aman Sharma
  • 1,930
  • 1
  • 17
  • 31

2 Answers2

4

This has been driving me crazy for a while. Running some of the Azure powershell commandlets with the -Debug flag let me reverse engineer some of the API calls.

Note, the below goes for backup management types of "AzureIaasVM". This hasn't been tested with other resources like SQL Servers.

From what I can tell (using API version '2016-06-01'), the default fabric name on Azure is just "Azure".

You can get the available containers at this endpoint:

https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.RecoveryServices/vaults/{vault_name}/backupProtectionContainers

It looks like a protection container may be created for every resource, with a name like this:

IaasVMContainer;iaasvmcontainerv2;{resource_group_name};{resource_name}

So if you have a VM called "my-awesome-vm" in a resource group "acme-rg", the protection container name would be:

IaasVMContainer;iaasvmcontainerv2;acme-rg;my-awesome-vm

And its full ID would be:

/subscriptions/{subscription_id}resourceGroups/acme-rg/providers/Microsoft.RecoveryServices/vaults/{vault_name}/backupFabrics/Azure/protectionContainers/IaasVMContainer;iaasvmcontainerv2;acme-rg;my-awesome-vm
Alecks Gates
  • 41
  • 1
  • 6
0

Well, I don't have an Azure Backup Vault to test, but there are ways to find that out with the REST API.

Get Fabrics: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics?api-version={api-version}
https://msdn.microsoft.com/en-us/library/azure/mt750478.aspx

Get Containers:
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{?api-version={api-version}
https://msdn.microsoft.com/en-us/library/azure/mt736896.aspx

Supported API Versions: '2016-08-10, 2016-06-01, 2016-05-01, 2015-12-15, 2015-12-10, 2015-11-10, 2015-06-10, 2015-08-10, 2015-08-15, 2015-03-15'

Also there's an ARMClient to help with REST Requests.

Or here's a quick Powershell script to query REST API (but you need .NET Azure SDK installed for this to work):

function GetAuthToken
{
    param
    (
            [Parameter(Mandatory=$true)]
            $ApiEndpointUri,

            [Parameter(Mandatory=$true)]
            $AADTenant
    )
    $adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\" + `
                "Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
    $adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\" + `
                    "Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"

    [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
    [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null

    $clientId = "1950a258-227b-4e31-a9cf-717495945fc2"
    $redirectUri = "urn:ietf:wg:oauth:2.0:oob"
    $authorityUri = “https://login.windows.net/$aadTenant”

    $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authorityUri

    $authResult = $authContext.AcquireToken($ApiEndpointUri, $clientId,$redirectUri, "Auto")

    return $authResult
}

$ApiEndpointUri = "https://management.azure.com/"
$AADTenant = 'Azure AD Tenant GUID'
$token = GetAuthToken -ApiEndPointUri $ApiEndpointUri -AADTenant $AADTenant
$header = @{
    'Content-Type'='application\json'
    'Authorization'=$token.CreateAuthorizationHeader()
}

$request = `https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics?api-version={api-version}`
(Invoke-RestMethod -Uri $request -Headers $header -Method Get).value
4c74356b41
  • 69,186
  • 6
  • 100
  • 141