How to quickly create a centos vm on Microsoft Azure with a reserved IP
This cmdlet allows you to quickly create a CentOS VM with a public IP, and Yes! :) I’ve inlcuded some addition goodies.
This file contains hidden or 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
##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 |