Script to provision Virtual machine on MS Azure:




  • Login to your Azure account with powershell.
  • Execute the command: Get-AzureVMImage
  • Select the Image name Which you want to provision.
  • Run the Following script which will create One storage account for your VM.
  • The Same script also Open HTTP Port 80.



# create Azure VM from images

clear-Host

$cloudServiceName = "sagar300"
$location = "Southeast asia"

$size = "Small"
$vmName = "sagarvm"

$adminUser = "sagar"
$password = "********"

$storename = "store123"


New-AzureStorageAccount -StorageAccountName $storename -Location $location -ErrorAction SilentlyContinue


$subsname = (Get-AzureSubscription).SubscriptionName

Set-AzureSubscription -SubscriptionId "$subsname" -CurrentStorageAccountName $storename

$imageFamily = "windows Server 2012 R2 Datacenter"

$imageName = "ad072bd3082149369c449ba5832401ae__Windows-Server-RDSHwO13P-on-Windows-Server-2012-R2-20151202-2013"


$vm1config = New-AzureVMConfig -Name $vmName -InstanceSize $size -ImageName $imageName |
             Add-AzureProvisioningConfig -Windows -AdminUsername $adminUser -Password $password |
             Add-AzureEndpoint -Name "HTTP" -Protocol tcp -PublicPort 80 -LocalPort 80


New-AzureVM -ServiceName $cloudServiceName -Location $location -VMs $vm1config

Popular posts from this blog

Certification for Kubernetes? I got it covered.

Continuous Integrations Concepts and Demo

What Happens Under the Hood of SSH Connections? Analyzing SSH Packets with Wireshark.