Created
March 9, 2018 12:55
-
-
Save rezamt/c7842b396b261e8ce62575300993e714 to your computer and use it in GitHub Desktop.
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
$stName = "<chosen storage account name>" | |
$locName = "<chosen Azure location name>" | |
$rgName = "TestRG" | |
New-AzureRmResourceGroup -Name $rgName -Location $locName | |
$storageAcc = New-AzureRmStorageAccount -ResourceGroupName $rgName -Name $stName | |
-Type "Standard_GRS" -Location $locName | |
$singleSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name singleSubnet | |
-AddressPrefix 10.0.0.0/24 | |
$vnet = New-AzureRmVirtualNetwork -Name TestNet -ResourceGroupName $rgName -Location $locName - AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet | |
$pip = New-AzureRmPublicIpAddress -Name TestPIP -ResourceGroupName $rgName -Location $locName - AllocationMethod Dynamic | |
$nic = New-AzureRmNetworkInterface -Name TestNIC -ResourceGroupName $rgName -Location $locName - SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id | |
$cred = Get-Credential -Message "Type the name and password of the local administrator account." | |
$vm = New-AzureRmVMConfig -VMName WindowsVM -VMSize "Standard_A1" | |
$vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName MyWindowsVM | |
-Credential $cred -ProvisionVMAgent -EnableAutoUpdate | |
$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest" | |
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id | |
$osDiskUri = $storageAcc.PrimaryEndpoints.Blob.ToString() + "vhds/WindowsVMosDisk.vhd" | |
$vm = Set-AzureRmVMOSDisk -VM $vm -Name "windowsvmosdisk" -VhdUri $osDiskUri | |
-CreateOption fromImage | |
New-AzureRmVM -ResourceGroupName $rgName -Location $locName -VM $vm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In azure powershell first created subnet and then v-net (added subnet to it) - subnet didn't asks for ARM
in azure cli its different, first v-net then used v-net name while creating the subnets.