Azure竞价型实例创建问题

时间:2020-04-30 00:47:59

标签: python azure azure-sdk azure-vm

我正在尝试使用python-sdk在Azure Cloud上创建竞价型实例,我按照文档设置了优先级和计费配置文件以及eviction_policy,但是当我在控制台上检查时,它附带了2020-04-30 00:17:47.280 LOG <spot> [vm_853k6w.create] INFO: payload...{'storage_profile': {'os_disk': {'caching': 'ReadWrite', 'vhd': {'uri': 'http://xykilk2luos08yzv0c1ol.blob.core.windows.net/vhds/2a048621-f37f-4148-be6e-759209056f80.vhd'}, 'name': '2a048621-f37f-4148-be6e-759209056f80', 'create_option': 'FromImage'}, u'image_reference': {u'sku': u'14.04.5-LTS', u'publisher': u'Canonical', u'version': u'latest', u'offer': u'UbuntuServer'}}, 'availability_set': {'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Compute/availabilitySets/cfyhwavailset0'}, u'hardware_profile': {u'vm_size': u'Standard_A0'}, u'priority': u'spot', 'network_profile': {'network_interfaces': [{'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkInterfaces/d7a6a799-0722-4512-bc8f-9c8a4b36bd53'}]}, u'billing_profile': {u'max_price': -1}, 'location': u'westus', u'eviction_policy': u'deallocate', 'os_profile': {u'linux_configuration': {u'disable_password_authentication': True, u'ssh': {u'public_keys': [{u'path': u'/home/ubuntu/.ssh/authorized_keys', u'keydata': u'RSA_PUBLIC_XXXXXXXXX'}]}}, 'computer_name': '2a048621-f37f-4148-be6e-759209056f80', u'admin_username': u'ubuntu'}} 2020-04-30 00:17:47.280 LOG <spot> [vm_853k6w.create] INFO: Create/Updating virtual_machine...2a048621-f37f-4148-be6e-759209056f80 2020-04-30 00:19:43.848 LOG <spot> [vm_853k6w.create] INFO: Create virtual_machine result: storage_profile : os_disk : disk_size_gb : 30 name : 2a048621-f37f-4148-be6e-759209056f80 caching : ReadWrite vhd : uri : http://xykilk2luos08yzv0c1ol.blob.core.windows.net/vhds/2a048621-f37f-4148-be6e-759209056f80.vhd os_type : Linux create_option : FromImage image_reference : sku : 14.04.5-LTS publisher : Canonical version : latest offer : UbuntuServer data_disks : [] availability_set : id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Compute/availabilitySets/CFYHWAVAILSET0 name : 2a048621-f37f-4148-be6e-759209056f80 vm_id : 7a55a3b3-d089-4c91-b394-6e5776c2ac15 os_profile : secrets : [] linux_configuration : disable_password_authentication : True provision_vm_agent : True ssh : public_keys : [{'key_data': u'PUBLIC_RSA_XXXXX', 'path': u'/home/ubuntu/.ssh/authorized_keys'}] allow_extension_operations : True admin_username : ubuntu computer_name : 2a048621-f37f-4148-be6e-759209056f80 provisioning_state : Succeeded network_profile : network_interfaces : [{'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkInterfaces/d7a6a799-0722-4512-bc8f-9c8a4b36bd53'}] location : westus id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Compute/virtualMachines/2a048621-f37f-4148-be6e-759209056f80 type : Microsoft.Compute/virtualMachines hardware_profile : vm_size : Standard_A0 2020-04-30 00:19:48.183 LOG <spot> [vm_853k6w.configure] INFO: Get network_interface...d7a6a799-0722-4512-bc8f-9c8a4b36bd53 2020-04-30 00:19:48.989 LOG <spot> [vm_853k6w.configure] INFO: Get network_interface result: dns_settings : dns_servers : [] applied_dns_servers : [] internal_domain_name_suffix : og1f4oigsjsu3p4lwy3lxrkywd.dx.internal.cloudapp.net virtual_machine : id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Compute/virtualMachines/2a048621-f37f-4148-be6e-759209056f80 name : d7a6a799-0722-4512-bc8f-9c8a4b36bd53 enable_accelerated_networking : False resource_guid : b21a670a-c972-4d46-a932-678068009b5b primary : True etag : W/"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" location : westus mac_address : 00-0D-3A-36-BA-26 provisioning_state : Succeeded ip_configurations : [{'subnet': {'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/virtualNetworks/cfyhwvn0/subnets/cfyhwsub0'}, 'private_ip_address_version': u'IPv4', 'primary': True, 'public_ip_address': {'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/publicIPAddresses/a7957e8c-1bff-4ca4-b751-d41eaba9270c'}, 'name': u'dec8c7c9-b9fa-43d4-a387-79cae431e4a2', 'private_ip_address': u'10.10.0.4', 'etag': u'W/"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX"', 'private_ip_allocation_method': u'Dynamic', 'id': u'/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkInterfaces/d7a6a799-0722-4512-bc8f-9c8a4b36bd53/ipConfigurations/dec8c7c9-b9fa-43d4-a387-79cae431e4a2', 'provisioning_state': u'Succeeded'}] enable_ip_forwarding : False type : Microsoft.Network/networkInterfaces id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkInterfaces/d7a6a799-0722-4512-bc8f-9c8a4b36bd53 network_security_group : id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkSecurityGroups/cfyhwnsg0 2020-04-30 00:19:49.647 LOG <spot> [vm_853k6w.configure] INFO: Get public_ip_address...a7957e8c-1bff-4ca4-b751-d41eaba9270c 2020-04-30 00:19:50.330 LOG <spot> [vm_853k6w.configure] INFO: Get public_ip_address result: name : a7957e8c-1bff-4ca4-b751-d41eaba9270c public_ip_address_version : IPv4 public_ip_allocation_method : Dynamic resource_guid : f6654f74-aac2-4822-9aef-8149b8b5018b provisioning_state : Succeeded etag : W/"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" location : westus type : Microsoft.Network/publicIPAddresses ip_configuration : id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/networkInterfaces/d7a6a799-0722-4512-bc8f-9c8a4b36bd53/ipConfigurations/dec8c7c9-b9fa-43d4-a387-79cae431e4a2 idle_timeout_in_minutes : 4 ip_address : XX.XX.XX.XX id : /subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/cfyhwrg0/providers/Microsoft.Network/publicIPAddresses/a7957e8c-1bff-4ca4-b751-d41eaba9270c 我的日志,这样您就可以看到我在有效负载中发送了什么,我从api返回的结果是

ComputeManagementClient

注意:'2019-03-01',api_version:create virtual_machine '2a048621-f37f-4148-be6e-759209056f80' failed with this error : Addition of a VM with managed disks to non-managed Availability Set or addition of a VM with blob based disks to managed Availability Set is not supported. Please create an Availability Set with 'Aligned' SKU in order to add a VM with managed disks to it. 当我尝试使avalabilityset对齐时,我遇到此错误

    def create_or_update(self, group_name, vm_name, params):
        self.logger.info(
            "Create/Updating virtual_machine...{0}".format(vm_name))
        create_async_operation = self.client.virtual_machines.create_or_update(
            resource_group_name=group_name,
            vm_name=vm_name,
            parameters=params,
        )
        create_async_operation.wait()
        virtual_machine = create_async_operation.result().as_dict()
        self.logger.info(
            'Create virtual_machine result: {0}'.format(
                utils.secure_logging_content(virtual_machine))
            )
        return virtual_machine

用于创建VM的代码段

{{1}}

有点想法不清了,是什么问题,但是非常感谢您指出我在做什么错的帮助

此致

1 个答案:

答案 0 :(得分:0)

非常感谢,解决方案是使用最新的API_VER,但是我没有注意的是,出现了更新的Azure-SDK ver 5 :(,所以是的,在那个版本中必须指定软件包,然后我添加了完整功能示例所需的

azure-mgmt-web==0.46.0
azure-mgmt-compute==12.0.0
azure-mgmt-containerservice==9.0.1
azure-mgmt-network==10.1.0
azure-mgmt-storage==9.0.0
azure-storage-common==2.1.0
azure-mgmt-resource==9.0.0
azure-common==1.1.25
msrestazure==0.6.3

瞧,它按预期enter image description here运行