Save-AzureVMImage
Save-AzureVMImage
Captures a virtual machine as a VMImage.
Syntax
Parameter Set: Default
Save-AzureVMImage [-ResourceGroupName] <String> [-VMName] <String> [-DestinationContainerName] <String> [-VHDNamePrefix] <String> [[-Overwrite]] [-Profile <AzureProfile> ] [ <CommonParameters>]
Detailed Description
The Save-AzureVMImage cmdlet captures 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-AzureVM cmdlet.
The output of this cmdlet is a JavaScript Object Notation (JSON) template. You can deploy virtual machines from your captured image.
Parameters
-DestinationContainerName<String>
Specifies the name of a container. 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.
Aliases |
none |
Required? |
true |
Position? |
3 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Overwrite
Indicates that this cmdlet overwrites any VHDs that have the same prefix in the destination container.
Aliases |
none |
Required? |
false |
Position? |
5 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Profile<AzureProfile>
Specifies the Azure profile from which this cmdlet reads. If you do not specify a profile, this cmdlet reads from the local default profile.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ResourceGroupName<String>
Specifies the name of the resource group of the virtual machine.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-VHDNamePrefix<String>
Specifies the prefix in the name of the blobs that constitute the storage profile of the VMImage. For example, a prefix vhdPrefix
for operating system disk results in the name vhdPrefix-osdisk
.
Aliases |
VirtualHardDiskNamePrefix |
Required? |
true |
Position? |
4 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
-VMName<String>
Specifies the name of the virtual machine that this cmdlet saves.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
Examples
Example 1: Capture a virtual machine
The first 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.
PS C:\> Set-AzureVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Generalized
PS C:\> Save-AzureVMImage -ResourceGroupName "ResourceGroup11" -VMName "VirtualMachine07" -DestinationContainerName "VMContainer01" -VHDNamePrefix "VM07"