Step-by-Step: Assign a Public IP to a VM in Azure

Hello Folks,

I’m sitting here reviewing my notes from the Azure IT Camps we have been running in the last quarter, and I keep seeing one recurring theme.  A lot of attendees wanted to know if there was a way to assign a public IP address directly to the a VM instead of the cloud service.  Doing so would make these VM directly addressable without having to map an endpoint for access.

This is called Instance-Level Public IPs and it’s I preview right now., you can enable scenarios such as running FTP servers in Azure and monitoring virtual machines directly using their IPs. This doesn’t take the place of the VIP that is assigned to your cloud service. Rather, it’s additional IP address that you can use to connect to your VM. You can assign one PIP for each VM.

While in Preview release, you can do this for 2 VMs within a subscription.  After GA that limitation will be removed.

IP Addresses in Azureimage

A VIP (Virtual IP address) is the public IP address assigned to the cloud service.  A  DIP (an internal IP assigned by Windows Azure with DHCP) is the IP address assigned to the VM for communicating within Windows Azure.  We covered before the way of assigning a static IP address to a VM (well, not really a static address, there is no such thing in Azure.  But an address with a very long reservation) Step-By-Step: Assigning VMs with Static IP addresses in a Virtual Network.


But now we can request a PIP.

An instance level public IP (PIP)

the PIP gives you difference scenarios.  By having a PIP on your VM, you can receive traffic on just about any port, you will not have to open up an endpoint to receive traffic. This enables scenarios where the ports are chosen dynamically.  The other scenario is to allow for outbound traffic originating from the VM goes out with PIP as the source and this uniquely identifies the VM to external entities.


Assigning a PIP to a VM using PowerShell

First step is to refresh your installation of the Azure PowerShell module. The PowerShell module are updated regularly.


Once the PowerShell Module is installed use the following command to set a new PIP to the VM

Get-AzureVM -ServiceName pr-net1 -Name vnet1-app-1 | Set-AzurePublicIP -PublicIPName Appip | Update-AzureVM

where “ServiceName” is the cloud service where your VM is deployed, “Name” is the name of the VM and “PublicIPName” is the name or the public IP.


once this succeeds you can retrieve the IP address by using the following command

Get-AzureRole -ServiceName pr-net1 -Slot Production -InstanceDetails


that’s it. now you can access that machine directly using that IP address.

Let me know if you have any scenarios you are looking into.



Pierre Roman
Twitter | Facebook | LinkedIn

Skip to main content