How to quickly create a centos vm on Microsoft Azure with a reserved IP

By

This cmdlet allows you to quickly create a CentOS VM with a public IP, and Yes! :) I’ve inlcuded some addition goodies.

##Start by Adding Azure Account
Add-AzureAccountz
#Configs
$subscription = "Pay-As-You-Go"
$vmname = "WEBSVR-001"
$username = "cloud-usr"
$pwd = "SUPERAWESOMEPASSWORD"
$instanceSize = "Small"
$cloudService = "WEB SERVICES"
$location = "South Central US"
$reservedIPname = "WEBSVR-001-ReservedIP"
#Finds CENTOS-6.5 Image
$image = Get-AzureVMImage |
where { $_.ImageName -Match "OpenLogic*"}|
sort PublishedDate -Descending |
select -ExpandProperty ImageName -Last 1
## Set Default Subscription
Select-AzureSubscription $subcription
#Request Reserved IP
New-AzureReservedIP -ReservedIPName $reservedIPname" -Location $location
#Verifiy Reserved IP created
Get-AzureReservedIP
#Creates VM with
New-AzureVMConfig -Name $vmname -InstanceSize Small -ImageName $image |
Add-AzureEndpoint -Name "HTTP" -Protocol "tcp" -PublicPort 80 -LocalPort 80 |
Add-AzureProvisioningConfig -Linux -LinuxUser $username" -Password $pwd |
New-AzureVM -ServiceName $cloudService -ReservedIPName $reservedIPname -Location $location
view raw gistfile1.ps1 hosted with ❤ by GitHub