使用python从azure中的磁盘创建linux虚拟机

2024-04-20 06:37:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python从azure中的磁盘创建一个Linux虚拟机。我找到了一些建议使用VHD进行操作的链接,但没有清楚地说明如何执行该操作。 有人能用python解释答案吗(不是在CLIpowershell或{}中)。在

我已经提到这个documentation

VM_PARAMETERS = {

            'location': LOCATION,
            'os_profile': {
                'computer_name': VM_NAME,
                'admin_username': USERNAME,
                'admin_password': PASSWORD
            },
            'hardware_profile': {
                'vm_size': 'Basic_A0'
            },
            'storage_profile': {
                'image_reference': {
                    'publisher': 'Canonical',
                    'offer': 'UbuntuServer',
                    'sku': '16.04.0-LTS',
                    'version': 'latest'
                },
            },
            'network_profile': {
                'network_interfaces': [{
                    'id': nic_id,
                }]
            },

}

compute_client.virtual_machines.create_or_update(GROUP_NAME, VM_NAME, VM_PARAMETERS)

请帮我拿这个。在


Tags: 答案nameidcliadmin链接linuxvm
1条回答
网友
1楼 · 发布于 2024-04-20 06:37:01

你特别问。。。在

Can anyone explain the answer using python (not on CLI or powershell or in JSON).

不过,你是在PowerShell问答论坛上问这个问题的。在

你不应该在python论坛上问这个问题吗? https://stackoverflow.com/questions/tagged/python

说的都是。VHD是虚拟硬盘。你必须有一个,首先在适当的地方,以连接到一个虚拟机,以启动一个虚拟机。在

How to create an Azure VM with the azurerm Python library

There are at least two ways to work with Azure infrastructure using Python. You can use the official Azure SDK for Python which supports all Azure functionality, or the azurerm REST wrapper library, which is unofficial and supports a subset of the Azure REST API.

https://msftstack.wordpress.com/2016/08/05/how-to-create-an-azure-vm-with-the-azurerm-python-library

相关问题 更多 >