Last Updated: February 25, 2016
· purekrome

Bulk-Adding Endpoints to an Azure VM

I had to create a large number of EndPoints for an Azure VM.

Here's the powershell script I used. HTH.


(and then enter your username/password in the 'popup' box)

then create a powershell file .. eg. addEndPoints.ps1

Select-AzureSubscription -SubscriptionName "----------"
$vm = Get-AzureVM -ServiceName "service-name-here" -Name "vm-name-here"
$startEndPoint = 62000
$endEndPointRange = 100
for ($i=1; $i -lt $endEndPointRange; $i++)
    $EndpointName = "FTP Data "
    $EndpointName += $i
    $localPort = $startEndPoint + $i
#Write-Output $EndpointName 
#Write-Output $localPort 
    Add-AzureEndpoint -Name $EndpointName -Protocol "tcp" -PublicPort $localPort  -LocalPort $localPort  -VM $vm
$vm | Update-AzureVM

To find out which subscription to use, type


To find out the VM's Service Name and VM's Name, type


after you've added your account AND selected your subscription. (That lists all the vm's for a subscription).

This script was heavily based upon this answer from my StackOverflow question.