How to assign a static Public IP to Azure VM

How to assign a static Public IP to Azure VM

An Azure Virtual Machine is an excellent computing resource provided by Microsoft and you need to pay based on your usage. Act as a server. Moreover, you can get the same user experience as your computer. In this article, we will discuss multiple ways to associate a Static Public IP address to your Azure Virtual Machine.

Azure VM Public IP

Basically, you need a Public IP address of a Virtual Machine to connect to the VM from the Internet. Public IP’s are of two types Dynamic and static.

When you create the Virtual Machine the system assigns a dynamic IP address to your Azure Virtual Machine and Each time you restart the Virtual Machine, the dynamic public IP changes to a new one.

It is really bit odd to see the Public IP of your Virtual Machine keep on changing always and most importantly it has many disadvantages for instance the script that contains your old Public IP will fail since the IP is changed now.

If you don’t want the Public IP of your Azure Virtual Machine to change always or to avoid this type of scenario, you can make the Public IP static and that’s where associating a static Public IP to your Azure Virtual Machine comes into the picture.

If at all you want to avoid this type of scenario and don’t want to use the Public IP address, as a better solution, you can use Azure VM FQDN.

How to assign a static Public IP to the Virtual Machine during the creation time

Now, let’s discuss how to assign a static Public IP to Azure VM.

Note that you can associate or assign a static Public IP while creating a new Virtual Machine as well as an existing Azure Virtual Machine.

During the creation of a new Virtual Machine, you can assign a new static IP address by following the below instruction.

  1. Log in to the Azure Portal.
  2. Search for “Virtual Machines” and click on the search result “Virtual Machines”.
  3. Click on the + Create option –> Azure Virtual Machine.
add public ip to azure vm

4. On the Create a virtual machine window fill in all the basic information on the Basics tab.

5. Now, click on the Networking Tab. For the Public IP option click on the Create new link to create a new Public IP.

how to add public ip to azure vm

6. On the Create public IP address window, provide a name for the public IP and make sure to select the Static option which is quite important —> Click on the OK button.

assign public ip to azure vm

Assign a static Public IP while creating a Virtual Machine using PowerShell

Check out how to assign a static Public IP to a Virtual Machine during creation time using PowerShell for a complete step-by-step tutorial.

How to assign a static Public IP address for an existing Virtual Machine

When you have already an existing Virtual Machine, in that case also you can able to assign a static Public IP address using the below instructions.

  1. Log in to the Azure Portal.
  2. Search for “Virtual Machines” and click on the search result “Virtual Machines”.
  3. Now you will see the list of Virtual Machines that you have created. Click on the one for that you want to change the Public IP address to Static.
  4. Click on the Networking option from the left navigation.
Assign a static Public IP address to an existing Virtual Machine

5. Now, click on the Network Interface option.

How to add a Static Public IP to an existing Azure VM

6. Click on the IP configurations option from the left navigation on the Network Interface page.

How to assign a static Public IP address to an existing Virtual Machine

7. Click the IP configuration (ipconfig 1).

How to add a static Public IP to an existing Virtual Machine

8. Under the Public IP address settings, click on the Create new link for the Public IP address option.

How to assign a static Public IP to an existing Azure Virtual Machine

9. Provide a name for the Public IP and make sure to select the assignment as Static. Then click on the Ok button and finally, click on the Save button to save the changes.

How to assign a static Public IP to an existing Azure VM

You may also like following the below articles

Wrapping Up

Well, In this article, we have discussed how to assign a static Public IP to the Azure Virtual to a new Virtual Machine as well as an existing Virtual machine.