There are scenarios when your VMs on Azure cloud will need a lot of EndPoints. Of course you have to always be aware of the limits that come with each Azure service. But you also don’t want to add 20 endpoints (or 50) via the management portal. It will be too painful.
Luckily you can extremely easy add as many endpoints as you will using the following simple PowerShell script:
Select-AzureSubscription -SubscriptionName "Your_Subscription_Name"
$vm = Get-AzureVM -ServiceName "CloudServiceName" -Name "VM_Name"
for ($i=6100; $i -le 6120; $i++)
$EndpointName = "FtpEndpoint_"
$EndpointName += $i
Add-AzureEndpoint -Name $EndpointName -Protocol "tcp" -PublicPort $i -LocalPort $i -VM $vm
$vm | Update-AzureVM
You can also find the whole script as a Gist.
Of course, you can use this script, with combination of Non-Interactive OrgID Login Azure PowerShell to fully automate your process.