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
Get-AzurePublishSettingsFile
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
Reset and manage your Active Directory users' Passwords Active Directory is one of the most…
Finding Exchange Database hidden mailboxes. Story:Maybe you have been in this situation before, trying to…
If you're using a Proxy server in your firewall or in your network and have…
Story:I got some clients that have reported some of their users being locked out and…
Delegate Permissions This is a code that I have wrote recently to check if an…
Story: I got a request from a client who constantly gets CVs and have to…