Skip to content

Instantly share code, notes, and snippets.

@PatrickLang
Last active June 5, 2017 22:24
Show Gist options
  • Save PatrickLang/d77fcf0d3252dfea3f9735767fc2df76 to your computer and use it in GitHub Desktop.
Save PatrickLang/d77fcf0d3252dfea3f9735767fc2df76 to your computer and use it in GitHub Desktop.
Visual Studio Trial VHD on Azure

There's a prebuilt VHD with Windows Server 2016, Visual Studio 2017, and more for hands on labs available from https://almvm.azurewebsites.net/labs/tfs/ . This will upload it to Azure and create a ready to run VM :)

Unfortunately as of 6/5, it doesn't work. I can't connect to it presumably because Remote Desktop isn't enabled or the firewall port isn't open

Download all parts

(Invoke-WebRequest https://almvm.azurewebsites.net/labs/tfs/almvm2017url.txt -UseBasicParsing).Content -split '\r?\n' | %{ Start-BitsTransfer $_ }

Extract

.\VisualStudio2017.RTM.ALM.part01.exe -d . -s

Upload to Azure & create managed disk

cd "Virtual Hard Disks"
$stor = Get-AzureRmStorageAccount # ... need parameters to get the right storage account
$rg = Get-AzureRmResourceGroup $stor.ResourceGroupName
$uri = $stor.PrimaryEndpoints[0].Blob + "vhdstore/ALMVM.vhd"
Add-AzureRmVhd -LocalFilePath .\ALMVM.vhd -Destination $uri -ResourceGroupName $rg.ResourceGroupName
$disk = New-AzureRmDisk -DiskName VS2017-ALM -Disk (New-AzureRmDiskConfig -AccountType PremiumLRS -Location southcentralus -CreateOption Import -SourceUri $uri) -ResourceGroupName $rg.ResourceGroupName

Create IP & NIC

# Create public ip
$pip = New-AzureRmPublicIpAddress -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -AllocationMethod Dynamic -DomainNameLabel ... -Name ...

# Create a vNIC
$vnet = Find-AzureRmResource -ResourceGroupName $rg.ResourceGroupName -ResourceType Microsoft.Network/virtualNetworks
$vnet = Get-AzureRmVirtualNetwork -ResourceName ... -ResourceGroupName ...
$nic = New-AzureRmNetworkInterface -Name BuildDemo_vnic -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -PublicIpAddressId $pip.Id -SubnetId $vnet.Subnets[0].Id

Create VM

# Get the availability set
$as = $rg | Get-AzureRmAvailabilitySet

# Create the starting vm config
$vmConfig = New-AzureRmVMConfig -VMSize "Standard_DS2" -AvailabilitySetId $as.Id -VMName ...
$vmConfig

# Add the vnic & disk to it
$vm = Add-AzureRmVMNetworkInterface -VM $vmConfig -Id $nic.Id
$vm = Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $disk.Id -StorageAccountType PremiumLRS -CreateOption Attach -Windows
$vm
$vm.AvailabilitySetReference.Id

# Actually create the vm. This will take minutes or longer if you don't have the azure agent installed
New-AzureRmVM -ResourceGroupName $rg.ResourceGroupName -Location $rg.Location -vm $vm

Getting Started guide has the login info - All accounts use the same password: P2ssw0rd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment