Save-​Azure​Rm​VM​Image

Saves a virtual machine as a VMImage.

Syntax

Save-AzureRmVMImage
    [-Id] <String>
    [-Name] <String>
    [-DestinationContainerName] <String>
    [-VHDNamePrefix] <String>
    [-Overwrite]
    [[-Path] <String>]
    [<CommonParameters>]
Save-AzureRmVMImage
    [-ResourceGroupName] <String>
    [-Name] <String>
    [-DestinationContainerName] <String>
    [-VHDNamePrefix] <String>
    [-Overwrite]
    [[-Path] <String>]
    [<CommonParameters>]

Description

The Save-AzureRmVMImage cmdlet saves a virtual machine as a VMImage. Before you create a virtual machine image, sysprep the virtual machine, and then mark it as generalized by using the Set-AzureRmVM cmdlet.

The output of this cmdlet is a JavaScript Object Notation (JSON) template. You can deploy virtual machines from your captured image.

Examples

Example 1: Capture a virtual machine

PS C:\> Set-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Generalized 
PS C:\> Save-AzureRmVMImage -ResourceGroupName "ResourceGroup11" -VMName "VirtualMachine07" -DestinationContainerName "VMContainer01" -VHDNamePrefix "VM07"

The first command marks the virtual machine named VirtualMachine07 as generalized.

The second command captures a virtual machine named VirtualMachine07 as a VMImage. The Output property returns a JSON template.

Required Parameters

-DestinationContainerName

Specifies the name of a container inside the "system" container that you want to hold your images.

If the container doesn't exist, it is created for you. The virtual hard disks (VHDs) that constitute the VMImage reside in the container that this parameter specifies. If the VHDs are spread across multiple storage accounts, this cmdlet creates one container that has this name in each storage account. The URL of the saved image is similar to:

https://<storageAccountName>.blob.core.windows.net/system/Microsoft.Compute/Images/<imagesContainer>/<vhdPrefix-osDisk>.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.vhd.

Type:String
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Id

Specifies the Resource ID of the virtual machine.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name

Specifies a name.

Type:String
Aliases:VMName
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName

Specifies the name of the resource group of the virtual machine.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VHDNamePrefix

Specifies the prefix in the name of the blobs that constitute the storage profile of the VMImage.

For example, a prefix vhdPrefix for an operating system disk results in the name vhdPrefix-osdisk.<guid>.vhd.

Type:String
Aliases:VirtualHardDiskNamePrefix
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-Overwrite

Indicates that this cmdlet overwrites any VHDs that have the same prefix in the destination container.

Type:SwitchParameter
Position:4
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Path

Specifies the path of the VHD.

Type:String
Position:5
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False