Last active
February 23, 2019 07:08
-
-
Save PatrickKalkman/474b3cb172e747b07bf21643ac5a1527 to your computer and use it in GitHub Desktop.
Create an Azure VM using an exported Snapshot via PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$virtualNetwork = New-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $ResourceGroupNameProd -Location $Location -AddressPrefix "10.0.0.0/16" | |
$backendSubnet = Add-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix "10.0.0.0/24" -VirtualNetwork $virtualNetwork | |
$virtualNetwork | Set-AzureRmVirtualNetwork | |
$pip = New-AzureRmPublicIpAddress -Name $IpAddressName -ResourceGroupName $ResourceGroupNameProd -Location $Location -AllocationMethod Dynamic | |
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $ResourceGroupNameProd -Location $Location -SubnetId "yoursubnetid" -PublicIpAddressId $pip.Id -PrivateIpAddress 10.0.0.101 | |
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize $VMSize | |
$vm = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id | |
$osDisk = New-AzureRmDisk -DiskName $osDiskName | |
-Disk (New-AzureRmDiskConfig -AccountType $storageAccountType -Location $Location -CreateOption Import -SourceUri $osDiskUri) -ResourceGroupName $ResourceGroupNameProd | |
$vm = Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -StorageAccountType $storageAccountType -DiskSizeInGB 128 -CreateOption Attach -Windows | |
$vm = Set-AzureRmVMBootDiagnostics -VM $vm -disable | |
#Create the new video workflow VM | |
New-AzureRmVM -ResourceGroupName $ResourceGroupNameProd -Location $Location -VM $vm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment