-1

我正在使用 python 脚本来创建虚拟机。我能够创建虚拟机。只是想添加可用性集功能。

<<一些片段>>

resource_client = ResourceManagementClient(credentials, subscription_id)
compute_client = ComputeManagementClient(credentials, subscription_id)
storage_client = StorageManagementClient(credentials, subscription_id)
network_client = NetworkManagementClient(credentials, subscription_id)

# 创建资源组 print('\nCreate Resource Group') resource_client.resource_groups.create_or_update(GROUP_NAME, {'location':LOCATION})

# Create a storage account
print('\nCreate a storage account')
storage_async_operation = storage_client.storage_accounts.create(
    GROUP_NAME,
    STORAGE_ACCOUNT_NAME,
    {
        'sku': {'name': 'standard_lrs'},
        'kind': 'storage',
        'location': LOCATION
    }
)
storage_async_operation.wait()

# Create a NIC
nic = create_nic(network_client)

<<>>

只是寻找可以创建可用性集的功能。我可以附加到多个虚拟机

4

1 回答 1

2

AvailabilitySet 有它自己的创建操作: http ://azure-sdk-for-python.readthedocs.io/en/latest/ref/azure.mgmt.compute.operations.html#azure.mgmt.compute.operations.AvailabilitySetsOperations.create_or_update

所以你的代码应该是这样的:

compute_client.availability_sets.create_or_update(
    group_name,
    availability_set_name,
    availability_set_parameters
)
于 2017-01-12T18:35:23.013 回答