我想在 azure 中使用 python 从磁盘创建 Linux 虚拟机。我找到了一些建议使用 VHD
做某事的链接,但没有清楚地解释如何做。
任何人都可以使用 python 解释答案吗(不是在 CLI
或 powershell
或 JSON
中)。
我已经提到了这个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)
请帮我解决这个问题。
最佳答案
你特意问...
Can anyone explain the answer using python (not on CLI or powershell or in JSON).
然而,您是在 PowerShell 问答论坛中提出问题。
你不应该在 python 论坛上问这个问题吗? https://stackoverflow.com/questions/tagged/python
话虽如此。 VHD 是虚拟硬盘。您必须首先有一个连接到 VM,以便启动虚拟机。
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
关于python - 使用 python 从 azure 中的磁盘创建 linux 虚拟机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48752707/