This in continuation of the last post on capturing or customizing image and deploy VM with the help of those images. Below is code that i used to create a customized image.
First we shutdown the VM and them generalized it and finally created the Image out of it.
$rgName = "RG"
$vmName = "Test-VM2"
$location = "west us"
$imageName = "testimage"
Stop-AzVM -ResourceGroupName $rgName -Name $vmName -Force
Set-AzVm -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName
$image = New-AzImageConfig -Location $location -SourceVirtualMachineId $vm.ID
New-AzImage -Image $image -ImageName $imageName -ResourceGroupName $rgName
First we shutdown the VM and them generalized it and finally created the Image out of it.
$rgName = "RG"
$vmName = "Test-VM2"
$location = "west us"
$imageName = "testimage"
Stop-AzVM -ResourceGroupName $rgName -Name $vmName -Force
Set-AzVm -ResourceGroupName $rgName -Name $vmName -Generalized
$vm = Get-AzVM -Name $vmName -ResourceGroupName $rgName
$image = New-AzImageConfig -Location $location -SourceVirtualMachineId $vm.ID
New-AzImage -Image $image -ImageName $imageName -ResourceGroupName $rgName
No comments:
Post a Comment