I'm trying to programmatically restore a database from Azure recovery services. I can list the protected database using graph api.
snippit:
// Get al backup protected items in resourcegroup/
string backupProtectedItemFilter = $"backupManagementType eq '{BackupManagementType.AzureWorkload}'";
var backupProtectedItems = resourceGroup.GetBackupProtectedItemsAsync(vaultName, backupProtectedItemFilter);
BackupProtectedItemResource? backupProtectedItemResource = null;
// backupProtectedItems is Pageable<> and does paging automatically
await foreach (BackupProtectedItemResource item in backupProtectedItems)
{
VmWorkloadSqlDatabaseProtectedItem temp = (item.Data.Properties as VmWorkloadSqlDatabaseProtectedItem);
Console.WriteLine($"Name: {item.Data.Name}, {temp.ServerName}, {temp.ParentName}");
}
I'm trying to get the original server for every backup, their source if you wil. For every "normal" sql db on a "normal" non cluster node I get both the server name and the instance name (in parentName) for every backup.
But when the backup is from a database that is in an Always on availability group, I get only the Availability group name and what might be a listener name. I tried retrieving the parent from azure graph, but the parent of an availability group is an availability group, not an instance apparently. Is there a way to get the instance name in this case and a specific node name even. (even the instance name would be great.
For now the only way I is to store a manual mapping from availability groups to instance names in my application, which I don't like.
Maybe the problem stems from me missing something in the relation between always on groups and sql instance names. Maybe they are 1:1?