Share via


Azure: Assign Static Public IP Address to VM

Overview

Microsoft Azure Virtual Machine (VM) provides flexibility of virtualization for various computing solutions with Windows server, Linux, SQL Server and many more. From the Microsoft Azure portal, we can set up an individual virtual machine or a farm of various virtual machines in an easy and quick way.
In this article, we will explore what public IP address brings in to a virtual machine, how we can assign static public IP address while creation, and on an existing VM.

Public IP for Azure VM

Microsoft Azure by default has a dynamic assignment of public IP address to newly created VM, unless we change it to be static. Public IP enables communication to Azure VM from the internet. Assigning a static public IP address ensures that the address never changes as opposed to a dynamic public IP address. 
The dynamic IP address changes every time when we restart the Azure VM. Generally, observed shortfalls of this are as follows:

  • On every restart of the virtual machine, we have to download the new remote desktop file (.rdp) to connect to it.
  • Few applications are configured to be run on a specific IP address or a range of IP addresses. A dynamic IP address might not work well in these scenarios.

Assign Static Public IP address to VM during creation

Microsoft Azure portal provides an easy way to create a virtual machine. The wizard to set up a new machine gathers the information about the virtual machine to be created. The information includes basic (name, region, image, size, credentials), disks, networking, management, guest configuration, tags, etc. The networking information includes the IP address configuration, which by default is dynamic. Follow the steps below to set up static public IP address. 

  1. Login to MS Azure portal (https://portal.azure.com)
  2. Click “Virtual Machines” from the left menu.
  3. Click “Add”.
  4. Add the basic information about the virtual machine to be set up.
  5. In the Networking tab, for Public IP click “Create new”.
  6. Under assign, select Static.
  7. Click OK.

Add Static Public IP to an existing Azure VM

Public IP address can be set on an existing virtual machine by following below steps.

  1. Login to MS Azure portal (https://portal.azure.com)
  2. Click “Virtual Machines” from the left menu.
  3. Select an existing virtual machine from the list.

  1. Under Settings, Click Networking.
  2. Click Network Interface.

  1. Under Settings, click IP Configurations.

  1. Click IP configuration (e.g. ipconfig1).
  2. Under Public IP address settings, for Public IP address click Enabled.
  3. Click “IP address”.
  4. Click “Create New”.
  5. Under Assignment, select Static.

  1. Click OK.
  2. Click Save to save the changes to a network interface.

Summary

Public IP address enables communication to Azure VM from the internet. Assigning a static public IP address ensures that the address never changes. Public IP can be assigned to a virtual machine during creation or afterwards.