简体   繁体   English

使用 python 创建 Azure 虚拟机问题

[英]Azure Virtual Machine creation issue using python

I am creating the Azure VM using Python and I am selecting the VM Size of a Particular region and for a particular CPU and Memory using the following custom function code.我正在使用 Python 创建 Azure VM,我正在使用以下自定义函数代码为特定区域和特定 CPU 和内存选择 VM 大小。

def list_vm_sizes_eq_cpu_memory(compute_client, region, cores, memory_MB,prefix):
    vm_sizes_list = compute_client.virtual_machine_sizes.list(location=region)
    vm_lists=[]    
    for vm_size in vm_sizes_list:
        if vm_size.number_of_cores == int(cores) and vm_size.memory_in_mb == int(memory_MB):            
            vm_lists.append(vm_size)
    
    return vm_lists

above function gives me the list of VM sizes and I pick the last record as the latest and create the VM using this size.上述函数为我提供了 VM 大小列表,我选择最后一条记录作为最新记录,并使用此大小创建 VM。

But the issue I am facing is that by using the size sometimes VM is created successfully but sometimes it gives the Error of Operation Config .但我面临的问题是,通过使用大小有时可以成功创建 VM,但有时会出现操作配置错误

There is also an issue of Premium Disk and Accelerated Network.还有一个高级磁盘和加速网络的问题。 Some VM Size supports Premium Disk and Accelerated Network某些 VM 大小支持高级磁盘和加速网络

Is there any way to identify that all VM Parameters are correct before creating the Azure VM using Python.在使用 Python 创建 Azure VM 之前,有什么方法可以确定所有 VM 参数都正确。

Also is there any way to identify the correct VM size based on CPU, Memory, Support Premium Disk, and Support Accelerated Network in a region and will not give any error while creating the Azure VM using Python.还有什么方法可以根据区域中的 CPU、内存、支持高级磁盘和支持加速网络来识别正确的 VM 大小,并且在使用 Python 创建 Azure VM 时不会出现任何错误。

Thanks in advance提前致谢

As I know both Premium Disk and Accelerated Network just support the VM size, not all.据我所知,Premium Disk 和 Accelerated Network 都只支持 VM 大小,而不是全部。 And the virtual_machine_sizes cannot contain the message that which one supports Premium Disk and Accelerated Network.并且virtual_machine_sizes不能包含支持高级磁盘和加速网络的消息。 So I recommend you can create two lists to store all the VM size that support them, one for Premium Disk and one for Accelerated Network.因此,我建议您可以创建两个列表来存储支持它们的所有 VM 大小,一个用于高级磁盘,另一个用于加速网络。 When you list all the available VM size in the special region, you can check if the available size exists in both two lists, if yes, then append the VM size into the vm_lists that you use in the above code.当您列出特殊区域中所有可用的VM大小时,您可以检查可用大小是否存在于两个列表中,如果是,则将VM大小附加到您在上述代码中使用的vm_lists中。

And the VM sizes support the Premium Disk, you can find the VM sizes and see it like this:并且 VM 大小支持 Premium Disk,您可以找到VM 大小并如下所示:

在此处输入图片说明

You can get VM sizes that support Accelerated Network here .您可以在此处获取支持加速网络的 VM 大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM