你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Save-AzureVMImage

捕获并保存已停止的 Azure 虚拟机的映像。

注意

本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧 Azure 资源。 创建新的资源时,不建议使用此旧版 PowerShell 模块,因为 ASM 计划停用。 有关详细信息,请参阅 Azure Service Manager 停用

Az PowerShell 模块是推荐的 PowerShell 模块,用于使用 PowerShell 管理 Azure 资源管理器 (ARM) 资源。

语法

Save-AzureVMImage
    [-ServiceName] <String>
    [-Name] <String>
    [-ImageName] <String>
    [[-ImageLabel] <String>]
    [[-OSState] <String>]
    [-Profile <AzureSMProfile>]
    [-InformationAction <ActionPreference>]
    [-InformationVariable <String>]
    [<CommonParameters>]

说明

Save-AzureVMImage cmdlet 捕获并保存已停止的 Azure 虚拟机的映像。 对于 Windows 虚拟机,请运行 Sysprep 工具,在捕获映像之前对其进行准备。 捕获映像后,将删除虚拟机。

示例

示例 1:保存现有虚拟机,然后将其从部署中删除

PS C:\> Save-AzureVMImage -ServiceName "MyService" -Name "MyVM" -NewImageName "MyBaseImage" -NewImageLabel "MyBaseVM"

此命令捕获现有虚拟机,并将其从部署中删除。

参数

-ImageLabel

指定虚拟机映像的标签。

类型:String
别名:NewImageLabel
Position:3
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-ImageName

指定虚拟机映像的名称。

类型:String
别名:NewImageName
Position:2
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-InformationAction

指定此 cmdlet 如何响应信息事件。

此参数的可接受值为:

  • 继续
  • 忽略
  • 询问
  • SilentlyContinue
  • 停止
  • Suspend
类型:ActionPreference
别名:infa
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-InformationVariable

指定信息变量。

类型:String
别名:iv
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Name

指定源虚拟机的名称。

类型:String
Position:1
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-OSState

指定虚拟机映像的操作系统状态。 如果要将虚拟机映像捕获到 Azure,请使用此参数。

有效值为:

  • 通用
  • 专用
类型:String
Position:4
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-Profile

指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。

类型:AzureSMProfile
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-ServiceName

指定 Azure 服务的名称。

类型:String
Position:0
默认值:None
必需:True
接受管道输入:True
接受通配符:False