Azure Spot 实例创建问题

Azure Spot Instance Creation issue

我正在尝试使用 python-sdk 在 Azure Cloud 上创建一个现货实例,我按照文档设置了优先级和计费配置文件以及 eviction_policy ,但是当我检查控制台它给出 Azure Spot: N/A ,附上我的日志,这样你就可以看到我在有效载荷中发送的内容 我从 api

得到的结果是什么
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

注释:ComputeManagementClient,api_version:'2019-03-01' 当我尝试使 avalabilityset 对齐时,我遇到了这个错误

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.

用于创建 VM 的代码片段

    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

有点儿 运行 没有想法,问题是什么,但非常感谢您帮助指出我做错了什么

此致,

谢谢,是的,解决方案是使用最新的 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

瞧,它正在按预期工作