
$VirtualMachine = New-AzureRmVMConfig -VMName $NewvirtualMachineName -VMSize $NewvirtualMachineSize $NIC = New-AzureRmNetworkInterface -Name ($NewvirtualMachineName.ToLower()+"_NIC") -ResourceGroupName $ResourceGroupName -Location $Location -SubnetId $

$VNet = Get-AzureRmVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $ResourceGroupName # 3 - Creating a new VM using the new managed disk we've created from a snapshot earlier. So the script below will create a new VM using an existing VNet, subnet, and a managed disk we've created earlier.

The last step requires us to attach the existing disk we've created to a new VM. $Snapshot=New-AzureRmSnapshot -Snapshot $SnapshotConfig -SnapshotName $SnapshotName -ResourceGroupName $ResourceGroupNameĪfter creating a new snapshot named "OnurSnapshot1" using the script block above, it should appear in the Azure "Snapshots" with the details such as source disk, creation time, and disk size.Ī new disk created from a snapshot Creating a VM using a managed disk $SnapshotConfig = New-AzureRmSnapshotConfig -SourceUri $Disk.Id -CreateOption Copy -Location $Location $Disk = Get-AzureRmDisk -ResourceGroupName $ResourceGroupName -DiskName $VMOSDisk $VMOSDisk=(Get-AzureRmVM -ResourceGroupName $ResourceGroupName -Name $VMName). # 1- Creating a snapshot using an existing VM managed disk. This operation basically creates a new copy of an existing VM disk, which could be either an OSDisk or a DataDisk. So what we need to do first is specify the VM details with which we will create a new snapshot using the existing managed disk.

Managed Disk details Creating a snapshot using a VM Disk
