fatihk
fatihk

Reputation: 7919

How to Set a Port Range to endpoint of a Virtual Machine at Azure?

In the Azure Interface, I could not find any field to enter port range. How can I do this instead of a single port? Thanks in advance.

Upvotes: 2

Views: 1723

Answers (3)

Oscar Foley
Oscar Foley

Reputation: 7025

There is also the option of opening endpoints from data contained in a CSV file as explained here (with code). @Dogan solution works but only for consecutive ports.

With I.ps1 you can use a CSV that is more convenient in many ocassions:

CSV screenshot

Upvotes: 1

tripdubroot
tripdubroot

Reputation: 1153

From the portal:

  1. Select the virtual machine
  2. Select the Endpoints "tab" at the top
  3. On the bottom of the page select "Add"

ref: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-set-up-endpoints/

UPDATE: For public endpoints, port ranges are not supported. You are also limited to 150 endpoints, so this could cause an issue if your range is larger than 150.

If the range is less than 150, you can use Azure PowerShell: Add-AzureEndpoint.

Upvotes: 4

dnkilic
dnkilic

Reputation: 238

Ports should be entered one by one from web interface. In order to enter range you should run powershell script. Default windows powershell dont support azure. So first of all, you should install Microsoft Azure Powershell.

  1. Download installer from this link and run it. http://go.microsoft.com/fwlink/p/?linkid=320376&clcid=0x409

  2. Run Microsoft AzurePowershell as Administrator. Get azure publish settings file with cmdlet which is given below. (You should login azure)

    Get-AzurePublishSettingsFile
  3. After you login with Get-AzurePublishSettingsFile cmdlet, opening page downloads a file. Enter this file with powershell command given below.

    Import-AzurePublishSettingsFile

    It should seem like this

    Import-AzurePublishSettingsFile .\publishfile.publishsettings

    Finally you can login azure account. Run the following cmdlet to view the entire membership information.

    Get-AzureSubscription

    VM under which port you want to open the subscription, select it with the following cmdlet.

    Select-AzureSubscription

    Lastly prepare a script like the following script with proper range.

       $i=5010
    $e=10
    do
    { Get-AzureVM -ServiceName "my_demo" -Name "my_demo" |
    Add-AzureEndpoint -LocalPort $i -PublicPort $i -Name RTP_$e -Protocol UDP |
    Update-AzureVM;
    $i+=1; $e+=1}
    until ($i -gt 5100)
    

Save script as ps1 and run it with powershell Note: Each port opening process takes 1-2 min.

Upvotes: 4

Related Questions