Create a virtual machine with a static public IP address using the Azure portal

In this article, you'll create a virtual machine (VM) with a static public IP address. A public IP address enables you to communicate to a VM from the internet. Assign a static public IP address, rather than a dynamic address, to ensure the address never changes.

Public IP addresses have a nominal charge. There's a limit to the number of public IP addresses that you can use per subscription.

You can download the list of ranges (prefixes) for the Azure Public, US government, China, and Germany clouds.

Prerequisites

Sign in to Azure

Sign in to the Azure portal.

Create a virtual machine

  1. In the search box at the top of the portal, enter Virtual machine.

  2. In the search results, select Virtual machines.

  3. Select + Create, then select Azure virtual machine.

  4. In Basics tab of Create a virtual machine, enter or select the following:

    Setting Value
    Project Details
    Subscription Select your Azure subscription
    Resource Group Select Create new.
    In Name, enter myResourceGroup.
    Select OK.
    Instance details
    Virtual machine name Enter myVM.
    Region Select East US.
    Availability Options Select No infrastructure redundancy required.
    Security type Select Standard.
    Image Select Windows Server 2019 Datacenter - x64 Gen2.
    Size Choose VM size or take default setting.
    Administrator account
    Username Enter a username.
    Password Enter a password.
    Confirm password Reenter password.
    Public inbound ports Select Allow selected ports.
    Select inbound ports Select RDP (3389).

    Warning

    Port 3389 is selected to enable remote access to the Windows Server virtual machine from the internet. Opening port 3389 to the internet is not recommended to manage production workloads.
    For secure access to Azure virtual machines, see What is Azure Bastion?

  5. Select the Networking tab, or select Next: Disks, then Next: Networking.

  6. In the Networking tab, enter or select the following:

    Setting Value
    Network interface
    Virtual network Accept the default network name.
    Subnet Accept the default subnet configuration.
    Public IP Select Create new.
    In Create public IP address, enter myPublicIP in Name .
    SKU: select Standard.
    Assignment: select Static.
    Select OK.
    NIC network security group Select Basic
    Public inbound ports Select Allow selected ports.
    Select inbound ports Select RDP (3389)

    Note

    The SKU of the virtual machine's public IP address must match the public IP SKU of Azure public load balancer when added to the backend pool of the load balancer. For details, see Azure Load Balancer.

  7. Select Review + create.

  8. Review the settings, and then select Create.

Warning

Do not modify the IP address settings within the virtual machine's operating system. The operating system is unaware of Azure public IP addresses. Though you can add private IP address settings to the operating system, we recommend not doing so unless necessary. For more information, see Add a private IP address to an operating system.

Note

Azure provides a default outbound access IP for VMs that either aren't assigned a public IP address or are in the backend pool of an internal basic Azure load balancer. The default outbound access IP mechanism provides an outbound IP address that isn't configurable.

The default outbound access IP is disabled when one of the following events happens:

  • A public IP address is assigned to the VM.
  • The VM is placed in the backend pool of a standard load balancer, with or without outbound rules.
  • An Azure NAT Gateway resource is assigned to the subnet of the VM.

VMs that you create by using virtual machine scale sets in flexible orchestration mode don't have default outbound access.

For more information about outbound connections in Azure, see Default outbound access in Azure and Use Source Network Address Translation (SNAT) for outbound connections.

Clean up resources

When no longer needed, delete the resource group and all of the resources it contains:

  1. Enter myResourceGroup in the search box at the top of the portal. When you see myResourceGroup in the search results, select it.

  2. Select Delete resource group.

  3. Enter myResourceGroup for TYPE THE RESOURCE GROUP NAME: and select Delete.

Next steps

In this article, you learned how to create a VM with a static public IP.