Blog‎ > ‎AZURE‎ > ‎

Add multiple endpoints or port range to an Azure Virtual Machine

If you ever needed to add multiple ports or range of ports endpoints to a particular Virtual machine on Azure. you might have a difficulty doing this since it’s not allowed by design and that will require time to do this manually for range of ports. that’s where this article comes handy.


To achieve this first you will need to connect to your Azure subscription on Azure powershell. Azure PowerShell.

Run Azure powershell as an administrator and type the following cmdlet to get your subscription info




This will open a page and ask you to sign in to your Azure user account and download a file called Visual Studio Premium with MSDN-DATE-credentials.publishsettings



In the powershell you will have to navigate to where the file is located. And import the settings that have just been downloaded in that file


Import-azurepublishSettingsFile `.\Visual Studio FileLocation`




You can check for your account and Subscription, using Get-azureaccount script



Now I have setup a ubuntu Machine on Azure that hosts Openfire Chat server which requires 10000-10005 port range for the media service. On Azure Web interface the port range option is not yet supported. The only available option is through powershell which will open the required port range for us.


To do so I'll use the following cmdlet highlighting the required information to enter


To create endpoints for ports 10000-10005:


$vm = Get-AzureVM -ServiceName moh10ly -Name ubunut-mohammed ; 10000..10005 | ForEach { $VM | Add-AzureEndpoint -Name TestEndpoint$_ -Protocol TCP -LocalPort $_ -PublicPort $_} ; $vm | Update-AzureVM


To Acquire your service name, you can simply login to Azure portal and check out All Items and see the cloud service name .. Just like the below screenshot




To Check your VMname simply navigate to Virtual machines tab and on the right side you can see the name.. I have copied it as well in the command.




Once you edited the cmdlet with your information you can enter it in the Powershell and enter


It should return something like this.




Once finished you can check Azure end point portal for the new ports configuration




Here we go .. Ports are created in Azure




To remove the endpoints for ports 10000-10005:


$vm = Get-AzureVM -ServiceName moh10ly -Name ubunut-mohammed ; 10000..10005 | ForEach { $VM | Remove-AzureEndpoint -Name TestEndpoint$_} ; $vm | Update-AzureVM


The gadget spec URL could not be found