0

我正在尝试使用 Python SDK 在 Azure 中创建恢复服务库。 包版本:azure-mgmt-recoveryservices==2.0.0

代码片段

client=RecoveryServicesClient(client_secret_credential, subscription_id)
client.vaults.begin_create_or_update(
    resource_group_name="my-custom-rg",
    vault_name="name_of_the_vault",
    vault={
        "location": "centralus", 
        "sku": {
            "name": "Standard",
        },
        "identity": {
            "type": "SystemAssigned",
        }
    }
)

我收到以下错误:

  File "/<my-computer-path>/azure/lib/python3.8/site-packages/azure/mgmt/recoveryservices/operations/_vaults_operations.py", line 293, in _create_or_update_initial
    raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'

我究竟做错了什么?我怎样才能做更多的“错误调查”?

4

1 回答 1

1

谢谢罗伯特。发布您的建议作为帮助其他社区成员的答案。

此错误azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'是由缺少backup_policy_resource属性引起的。

policy_resource = BaseBackupPolicyResource(properties=backup_policy)
poller = client.backup_policies.create_or_update(
    vault_name="my-vault-name",
    resource_group_name="my-resource-group",
    backup_policy_name="my-daily-backup",
    parameters=policy_resource
)

您可以参考如何使用 azure python SDK 创建磁盘备份策略?

于 2021-11-08T12:15:01.007 回答