Azure Recovery Backup Recovery: {CloudError}AzureError Resource Not Found

103 Views Asked by At

with respect to Azure Recovery Services Question, I am using this code to fetch details of all vaults inside resource vault services:

all_vault_in_rsv = []
def all_vaults():
    for rsv in res_vault_grps:
        all_resources = resource_management_client.resources.list_by_resource_group(resource_group_name=rsv)
        for res in all_resources:
            all_vault_in_rsv.append([res.name,rsv])
    return all_vault_in_rsv
all_vaults_in_rsg = all_vaults()

So in the above code, I have collected all vault-names and its respective resource groups name referenced to all_vaults_in_rsg variable. Now when I try to derive the backup_usage_summary for all vaults using the following:

def recovery_usage_summaries():
    # for res_vault_grp in res_vault_grps:
    for vault, rsg in all_vaults_in_rsg:
        try:
            usage_summary_iterator = recovery_backup_client.backup_usage_summaries(resource_group_name=rsg,
                                                          vault_name=vault)
        except Exception as e:
            return f"An error of type {e.__class__.__name__} has occurred while fetching usage summaries"
        else:
            try:
                for usage in usage_summary_iterator:
                    usage_summary_list.append(usage.name)
            except Exception as e:
                return f"An error of type {e.__class__.__name__} has occurred. Error says: {e}"
    return usage_summary_list
usage_summary_list = recovery_usage_summaries()

Now when I debug the above code, the usage_summary_iterator fails to iterate in the first iteration with an error saying:

Message: The Resource 'Microsoft.RecoveryServices/vaults/<vault.name>' under resource group '<resource_group>' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Expected result was to have usage summaries stored inside usage_summary_list for all the vaults as all_vaults_in_rsg is the same list of vault_name & resource_group_name that is fetched from azure. How is it that recovery_usage_vaults() renders a resource not found error? Is it a semantic error or is it a bug in the azure-sdk package?

Environment Details: 
azure-mgmt-recoveryservicesbackup==0.8.0
azure-mgmt-resource==10.1.0
python=3.8
0

There are 0 best solutions below