你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Azure 虚拟机库
概述
运行 Linux 或 Windows 的按需可缩放计算资源。
若要开始使用 Azure 虚拟机,请参阅使用 Azure 门户创建 Linux 虚拟机。
管理 API
使用管理 API 通过代码在 Azure 中创建、配置、管理和缩放 Windows 与 Linux 虚拟机。
通过 pip 安装库。
pip install azure-mgmt-compute
示例
使用托管服务标识 (MSI) 身份验证在现有 Azure 资源组中创建新的 Linux 虚拟机。
VM_PARAMETERS={
'location': 'LOCATION',
'os_profile': {
'computer_name': 'VM_NAME',
'admin_username': 'USERNAME',
'admin_password': 'PASSWORD'
},
'hardware_profile': {
'vm_size': 'Standard_DS1_v2'
},
'storage_profile': {
'image_reference': {
'publisher': 'Canonical',
'offer': 'UbuntuServer',
'sku': '16.04.0-LTS',
'version': 'latest'
},
},
'network_profile': {
'network_interfaces': [{
'id': 'NIC_ID',
}]
},
}
def create_vm()
compute_client.virtual_machines.create_or_update(
'RESOURCE_GROUP_NAME', 'VM_NAME', VM_PARAMETERS)
示例
查看虚拟机示例的完整列表。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈