Upload your Fedora Server VM and run it on Azure.

So you’ve prepped your VHD file and want to give it some Xeon processors and some generous RAM? Let’s deploy it on Azure, and set up a development environment.
The first step is to use PowerShell to upload your VHD and create the virtual machine. In this post we’ll simply use the command line for each step, but in the future when we set up homogenous clusters we’ll use templates to avoid typing so much. The first step now is to install the Azure command line tools for PowerShell. Open a prompt with administrative privileges and type:

Install-Module AzureRM
Install-AzureRM
Install-Module Azure
Import-AzureRM
Import-Module Azure
Login-AzureRMAccount
$subscriptionId =
    (Get-AzureRmSubscription |
     Out-GridView `
        -Title "Select an Azure Subscription ..." `
        -PassThru).SubscriptionId
Select-AzureRmSubscription -SubscriptionId $subscriptionId

I chose to place my machine in the East US 2 datacenter because that’s where a lot of preview features like DataLake Storage are launched first. One thing to keep in mind is that there is a 200ms+ latency from Europe to the US which can be a bit irritating when working with an interactive terminal, but because a lot of the interactions we intend to do go through web-portals it won’t matter too much.
Now change directory to where your VHD is and take the time to modify the following commands and understand what each one does. Take note of the naming conventions. With one machine it’s not necessary to be picky, but as soon as you start working with clusters, you’ll be thankful you were systematic about naming your Azure components from the start.

# here we set up the variables
$ResourceGroupName = "LT-Labs"
$Location = "eastus2"
$StorageName = "ltlabs01storage01"
$StorageType = "Standard_LRS"
$DiskName = "ltlabs01osdisk01.vhd"
$OSDiskUri = "https://ltlabs01storage01.blob.core.windows.net/vhds/"
$InterfaceName = "ltlabs01nic01"
$DomainName = "ltlabs01"
$IpName = $InterfaceName + "ip"
$VNetName = "vnet01"
$SubnetName = "vnet01subnet01"
$VNetAddressPrefix = "10.0.0.0/16"
$VNetSubnetAddressPrefix = "10.0.0.0/24"
$VMName = "ltlabs01"
$ComputerName = "ltlabs01"
$VMSize = "Basic_A3"
$SecurityGroupName = "vnet01subnet01security"
$SecurityRulePriority = 100
$SecurityRule = "SSH"
$SecurityRuleDescription = "Allow inbound SSH connections."
$SecurityRulePort = 22
# here we create the Resource Group, Storage, IP, VNet, NIC, and Firewall
New-AzureRmResourceGroup -Name $ResourceGroupName `
                         -Location $Location
$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName `
                                            -AccountName $StorageName `
                                            -Type $StorageType `
                                            -Location $Location
$PIp = New-AzureRmPublicIpAddress -Name $IpName `
                                  -ResourceGroupName $ResourceGroupName `
                                  -Location $Location `
                                  -DomainNameLabel $DomainName `
                                  -AllocationMethod Dynamic
$SubnetConfig = New-AzureRmVirtualNetworkSubnetConfig `
                -Name $SubnetName `
                -AddressPrefix $VNetSubnetAddressPrefix
$VNet = New-AzureRmVirtualNetwork -Name $VNetName `
                                  -ResourceGroupName $ResourceGroupName `
                                  -Location $Location `
                                  -AddressPrefix $VNetAddressPrefix `
                                  -Subnet $SubnetConfig
$Interface = New-AzureRmNetworkInterface -Name $InterfaceName `
                                         -ResourceGroupName $ResourceGroupName `
                                         -Location $Location `
                                         -SubnetId $VNet.Subnets[0].Id `
                                         -PublicIpAddressId $PIp.Id
$SecurityRules = New-AzureRmNetworkSecurityRuleConfig `
                  -Name $SecurityRule `
                  -Description $SecurityRuleDescription `
                  -Access Allow `
                  -Protocol "TCP" `
                  -Direction Inbound `
                  -Priority $SecurityRulePriority `
                  -SourceAddressPrefix * `
                  -SourcePortRange * `
                  -DestinationAddressPrefix * `
                  -DestinationPortRange $SecurityRulePort
$NetworkSecurityGroup = New-AzureRmNetworkSecurityGroup `
                        -Name $SecurityGroupName `
                        -ResourceGroupName $ResourceGroupName `
                        -Location $Location `
                        -SecurityRules $SecurityRules
Set-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VNet `
                                      -Name $SubnetName `
                                      -AddressPrefix $VNetSubnetAddressPrefix `
                                      -NetworkSecurityGroup $NetworkSecurityGroup |
                                      Set-AzureRmVirtualNetwork
# here we upload the Fedora VHD
$VhdUri = $OSDiskUri + $DiskName
Add-AzureRmVhd -Destination $VhdUri `
               -LocalFilePath $DiskName `
               -ResourceGroupName $ResourceGroupName
# here we create the template for our new VM
$VirtualMachine = New-AzureRmVMConfig -VMName $VMName `
                                      -VMSize $VMSize
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine `
                                                -Id $Interface.Id
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine `
                                      -Name $DiskName `
                                      -VhdUri $VhdUri `
                                      -CreateOption attach `
                                      -Caching ReadWrite `
                                      -Linux
# now we spin up the VM and test!
New-AzureRmVM -ResourceGroupName $ResourceGroupName `
              -Location $Location `
              -VM $VirtualMachine

That’s it.
Now you can see your new machine at http://portal.azure.com and SSH in!
Azure1