用于创建和管理 Linux VM 的 Azure VM PowerShell 示例Azure VM PowerShell samples for creating and managing Linux VMs

下表包含用于创建和管理 Linux 虚拟机的 PowerShell 脚本示例的链接。The following table includes links to PowerShell scripts samples that create and manage Linux virtual machines.

ScriptScript 说明Description
创建虚拟机Create virtual machines
创建完全配置的虚拟机Create a fully configured virtual machine 创建资源组、虚拟机以及所有相关资源。Creates a resource group, virtual machine, and all related resources.
创建已启用 Docker 的 VMCreate a VM with Docker enabled 创建一个虚拟机,将此 VM 配置为 Docker 主机,并运行 NGINX 容器。Creates a virtual machine, configures this VM as a Docker host, and runs an NGINX container.
创建 VM 并运行配置脚本Create a VM and run configuration script 创建一个虚拟机,并使用 Azure 自定义脚本扩展安装 NGINX。Creates a virtual machine and uses the Azure Custom Script extension to install NGINX.
创建安装有 WordPress 的 VMCreate a VM with WordPress installed 创建一个虚拟机,并使用 Azure 自定义脚本扩展安装 WordPress。Creates a virtual machine and uses the Azure Custom Script extension to install WordPress.
从托管 OS 磁盘创建 VMCreate a VM from a managed OS disk 通过将现有托管磁盘附加为 OS 磁盘来创建虚拟机。Creates a virtual machine by attaching an existing Managed Disk as OS disk.
从快照创建 VMCreate a VM from a snapshot 通过先从快照创建托管磁盘,然后将新的托管磁盘附加为 OS 磁盘来从快照创建虚拟机。Creates a virtual machine from a snapshot by first creating a managed disk from the snapshot and then attaching the new managed disk as OS disk.
管理存储Manage storage
在相同或不同的订阅中从 VHD 创建托管磁盘Create a managed disk from a VHD in the same or a different subscription 在相同或不同订阅中,从专用 VHD 将托管磁盘创建为 OS 磁盘,或从数据 VHD 将托管磁盘创建为数据磁盘。Creates a managed disk from a specialized VHD as an OS disk, or from a data VHD as a data disk, in the same or a different subscription.
从快照创建托管磁盘Create a managed disk from a snapshot 从快照创建托管磁盘。Creates a managed disk from a snapshot.
将快照作为 VHD 导出到存储帐户Export a snapshot as a VHD to a storage account 将托管快照作为 VHD 导出到不同区域中的存储帐户。Exports a managed snapshot as a VHD to a storage account in a different region.
将托管磁盘的 VHD 导出到存储帐户Export the VHD of a managed disk to a storage account 将托管磁盘的基础 VHD 导出到不同区域的存储帐户。Exports the underlying VHD of a managed disk to a storage account in a different region.
从 VHD 创建快照Create a snapshot from a VHD 从 VHD 创建快照,然后使用该快照快速创建多个相同的托管磁盘。Creates a snapshot from a VHD and then uses that snapshot to create multiple identical managed disks quickly.
将快照复制到相同或不同的订阅Copy a snapshot to the same or a different subscription 将快照复制到父快照所在区域中的相同或不同订阅。Copies snapshot to the same or a different subscription that is in the same region as the parent snapshot.
监视虚拟机Monitor virtual machines
使用 Azure Monitor 日志监视 VMMonitor a VM with Azure Monitor logs 创建一个虚拟机,安装 Log Analytics 代理,并在 Log Analytics 工作区中注册该 VM。Creates a virtual machine, installs the Log Analytics agent, and enrolls the VM in a Log Analytics workspace.
将托管磁盘复制到相同或不同的订阅Copy a managed disk to the same or a different subscription 将托管磁盘复制到父托管磁盘所在区域中的相同或不同订阅。Copies a managed disk to the same or a different subscription that is in the same region as the parent managed disk.
使用 PowerShell 收集订阅中所有 VM 的详细信息Collect details about all VMs in a subscription with PowerShell 创建一个 csv,其中包含所提供订阅中 VM 的 VM 名称、资源组名称、区域、虚拟网络、子网、专用 IP 地址、OS 类型和公共 IP 地址。Creates a csv that contains the VM Name, Resource Group Name, Region, Virtual Network, Subnet, Private IP Address, OS Type, and Public IP Address of the VMs in the provided subscription.