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. This article will discuss multiple ways to associate a Static Public IP address with your Azure Virtual Machine.

Azure VM Public IP

You need a Public IP address of a Virtual Machine to connect to the VM from the Internet. Public IPs 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 odd to see your Virtual Machine’s Public IP keep changing, 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.

Suppose you don’t want the Public IP of your Azure Virtual Machine to change always or to avoid this type of scenario. In that case, 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 you want to avoid this type of scenario and don’t want to use the Public IP address, you can use Azure VM FQDN as a better solution.

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.

You can associate or assign a static Public IP while creating a new Virtual Machine and an existing Azure Virtual Machine.

When creating a new Virtual Machine, you can assign a new static IP address by following the below instructions.

  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 essential 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.

azure add public ip to vm

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

azure add public ip to 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 step-by-step tutorial.

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

When you already have a Virtual Machine, you can assign a static Public IP address using the instructions below.

  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 you created. Click on the one where you want to change the Public IP address to Static.
  4. Click on the Networking option from the left navigation.
assign public ip to azure vm

5. Now, click on the Network Interface option.

how to associate public ip to azure vm

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

how to add public ip to azure vm

7. Click the IP configuration (ipconfig 1).

add public ip address to azure vm

8. Click the Create new link for the Public IP address option under the Public IP address settings.

how to add public ip in azure vm

9. Provide a name for the Public IP and 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 articles below

Wrapping Up

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