Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure python sdk,如何部署vm及其Azure Spot实例_Python_Azure Sdk Python - Fatal编程技术网

Azure python sdk,如何部署vm及其Azure Spot实例

Azure python sdk,如何部署vm及其Azure Spot实例,python,azure-sdk-python,Python,Azure Sdk Python,Azure python sdk, 如何部署vm及其Azure Spot实例如果要创建Azure Spot vm,请参考以下代码。有关更多死亡信息,请参阅和 你还有其他顾虑吗?如果你没有其他问题,请你。它可以帮助有类似问题的人。 from azure.common.credentials import ServicePrincipalCredentials from azure.mgmt.compute.v2019_07_01 import ComputeManagementClient fro

Azure python sdk,
如何部署vm及其Azure Spot实例如果要创建Azure Spot vm,请参考以下代码。有关更多死亡信息,请参阅和


你还有其他顾虑吗?如果你没有其他问题,请你。它可以帮助有类似问题的人。
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.compute.v2019_07_01 import ComputeManagementClient
from azure.mgmt.compute.v2019_07_01.models import VirtualMachinePriorityTypes, VirtualMachineEvictionPolicyTypes, BillingProfile
SUBSCRIPTION_ID = 'subscription-id'
GROUP_NAME = 'myResourceGroup'
LOCATION = 'westus'
VM_NAME = 'myVM'
credentials = ServicePrincipalCredentials(
        client_id = 'application-id',
        secret = 'authentication-key',
        tenant = 'tenant-id'
    )
compute_client = ComputeManagementClient(
    credentials,
    SUBSCRIPTION_ID
)
vm_parameters = {
        'location': LOCATION,
        'os_profile': {
            'computer_name': VM_NAME,
            'admin_username': 'azureuser',
            'admin_password': 'Azure12345678'
        },
        'hardware_profile': {
            'vm_size': 'Standard_DS1'
        },
        'storage_profile': {
            'image_reference': {
                'publisher': 'MicrosoftWindowsServer',
                'offer': 'WindowsServer',
                'sku': '2012-R2-Datacenter',
                'version': 'latest'
            }
        },
        'network_profile': {
            'network_interfaces': [{
                'id': nic.id
            }]
        },
        'priority':VirtualMachinePriorityTypes.spot, # use Azure spot intance
        'eviction_policy':VirtualMachineEvictionPolicyTypes.deallocate , #For Azure Spot virtual machines, the only supported value is 'Deallocate'
        'billing_profile': BillingProfile(max_price=float(2)) 
creation_result = compute_client.virtual_machines.create_or_update(
        GROUP_NAME, 
        VM_NAME, 
        vm_parameters
    )
print(creation_result.result())
    }