Assign Static Public IP Address To Azure 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 a public IP address brings to the virtual machine, how we can assign a static public IP address during creation of a VM, and how it works on an existing VM.
 

Public IP for Azure VM

 
Microsoft Azure by default has a dynamic assignment of a public IP address to a 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 the dynamic public IP address.
 
The dynamic IP address changes every time we restart the Azure VM. Generally, observed pitfalls of this are as below.
  • On every restart of the virtual machine, we have to download the new remote desktop file (.rdp) to connect to it.
  • A few applications are configured to be run on a specific IP address or a range of IP addresses. The Dynamic IP address might not work well in these scenarios.

Assign Static Public IP address to VM during the 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 things (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 below steps to set up a static public IP address.
  1. Login to MS Azure portal
  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.
Assign Static Public IP Address To Azure VM

Add Static Public IP to an existing Azure VM

 
A public IP address can be set on existing virtual machines by following the below steps.
  1. Login to MS Azure portal
  2. Click “Virtual Machines” from the left menu.
  3. Select an existing virtual machine from the list.

    Assign Static Public IP Address To Azure VM 

  4. Under Settings, click "Networking".
  5. Click "Network Interface".

    Assign Static Public IP Address To Azure VM
     
  6. Under Settings, click "IP Configurations".

    Assign Static Public IP Address To Azure VM 

  7. Click IP configuration (e.g. ipconfig1).
  8. Under Public IP address settings, for Public IP address click Enabled.
  9. Click “IP address”.
  10. Click “Create New”.
  11. Under Assignment, select Static.

    Assign Static Public IP Address To Azure VM 

  12. Click OK.
  13. Click Save to save the changes to the network interface.

Summary

 
A public IP 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 afterward.