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

标签 python linux amazon-web-services azure

我想在 azure 中使用 python 从磁盘创建 Linux 虚拟机。我找到了一些建议使用 VHD 做某事的链接,但没有清楚地解释如何做。 任何人都可以使用 python 解释答案吗(不是在 CLIpowershellJSON 中)。

我已经提到了这个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/

相关文章:

Linux 中颜色响应的正则表达式匹配

amazon-web-services - 将 AWS EC2 实例移动到另一个账户

python - 以字符串格式返回的字符串数平均值

linux - 无法运行命令来运行 Code Composer

linux - 为什么 Linux 中的 iconv 不能正确地将 UTF-8 中的西类牙字符转换为 ISO-8859-1

amazon-web-services - Ansible Script dpkg lock on aws 启动 ubuntu 16.04

amazon-web-services - 具有共享内容库的大型用户群的云搜索解决方案

python - 检查数字是否以 5 结尾?

python - elasticsearch映射没有JSON对象错误

python - 管理多个 settings.py 文件