Using Powershell to create VMs in Azure

Occasional Visitor

I Have a powershell script we use to create VM. It uses a generalized snapshot to make the build but I want to switch to using an image so I can load the image instal a gallery instead of having to copy the same snapshot to different RGs. I cam create and images from the snapshot but I cant work our how to modify my power shell to refer to the image instead of the snapshot


the relevant section: is

$snapshot = 'SLES12-SP4-xxxxxxxx-BUILD-0001'

$snapshotName = Get-AzureRmSnapshot -ResourceGroupName $rg -SnapshotName $snapshot


$diskConfig = New-AzureRmDiskConfig -DiskSizeGB 200 -AccountType $storageType -Location $region -SourceResourceId $snapshotName.Id -OsType Linux -CreateOption Copy

$vmDisk = New-AzureRmDisk -ResourceGroupName $rg -DiskName $vmOSdiskName -Disk $diskConfig

$MyVM = Set-AzureRmVMOSDisk -VM $MyVM -ManagedDiskId $vmDisk.Id -CreateOption Attach -Linux


Can anyone advice on the syntax please

0 Replies