Customized Azure VM Image - Powershell

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

No comments:

Post a Comment

Risk Vs Constraints

 The distinction between risks and constraints lies in their nature and impact on the project. Here's how they differ: 1. Nature Risks...