1

关于Azure 恢复服务问题,我正在使用此代码来获取资源库服务中所有库的详细信息:

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()

因此,在上面的代码中,我收集了所有 vault-names 及其引用到all_vaults_in_rsg变量的相应资源组名称。现在,当我尝试使用以下命令为所有保管库派生 backup_usage_summary 时:

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()

现在,当我调试上面的代码时,usage_summary_iterator在第一次迭代中迭代失败并显示错误消息:

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

预期的结果是将所有保管库的使用摘要存储在 usage_summary_list中,与从 azure 获取的&all_vaults_in_rsg列表相同。如何呈现资源未找到错误?它是语义错误还是 azure-sdk 包中的错误?vault_nameresource_group_namerecovery_usage_vaults()

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

0 回答 0