Auto-create VM with instance level IP (full script)

Tags: azure, image creation, powershell

# tested and working, manually get image name, adjust image size, instance ip works too, storage account must already exist though #
Set-AzureSubscription -SubscriptionId "xxxxx-xxxxx-xxxxx-xxxxx-xxxxxx" -CurrentStorageAccountName (Get-AzureStorageAccount).Label -PassThru
$image = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2016-Datacenter-20161213-en.us-127GB.vhd"
$pwd = "xxxxxxx"
$un = "admin"
New-AzureVMConfig -Name "server1" -InstanceSize "Small" -Image $image |
Add-AzureProvisioningConfig -Windows -AdminUserName $un -Password $pwd |
Set-AzurePublicIP -PublicIPName server1pip |
New-AzureVM -ServiceName "server1" -Location "East US 2" -ReverseDnsFqdn "server1.cloudapp.net."

1 Comment

  • researchadmin said Reply

    Instance IP is static, but maybe the virtual IP isn't. It might be an idea to reserve the public Virtual IP to make that static too.

    Probably should default the server to A2 (basic 2-core), instead of "Small" which is the Standard Small (1 core 3.5GB RAM).

    I didn't really test the ReverseDNS though, not sure how to.

You must log on to comment.