Quickstart: Create a public IP address using the Azure CLI

In this quickstart, you'll learn how to create an Azure public IP address. Public IP addresses in Azure are used for public connections to Azure resources. Public IP addresses are available in two SKUs: basic, and standard.

Diagram of an example use of a public IP address. A public IP address is assigned to a load balancer.

If you don't have an Azure trail subscription, create a trial subscription before you begin.

Prerequisites

  • If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.

    • If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.

    • When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.

    • Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.

  • This tutorial requires version 2.0.28 or later of the Azure CLI.

Create a resource group

An Azure resource group is a logical container into which Azure resources are deployed and managed.

Create a resource group with az group create named QuickStartCreateIP-rg in the chinanorth3 location.

  az group create \
    --name QuickStartCreateIP-rg \
    --location chinanorth3

Create public IP

Note

Standard SKU public IP is recommended for production workloads. For more information about SKUs, see Public IP addresses.

The following command works for API version 2020-08-01 or later. For more information about the API version currently being used, please refer to Resource Providers and Types.

Use az network public-ip create to create a standard zone-redundant public IPv4 address named myStandardPublicIP in QuickStartCreateIP-rg.

To create an IPv6 address, modify the --version parameter to IPv6.

  az network public-ip create \
    --resource-group QuickStartCreateIP-rg \
    --name myStandardPublicIP \
    --version IPv4 \
    --sku Standard \
    --zone 1 2 3

Important

For versions of the API older than 2020-08-01, execute the command without specifying a --zone parameter to create a zone-redundant IP address.

Create a zonal or no-zone IP address

In this section, you learn how to create a zonal or no-zone public IP address.

To create a standard zonal public IPv4 address in Zone 2 named myStandardPublicIP in QuickStartCreateIP-rg, use the following command.

To create an IPv6 address, modify the --version parameter to IPv6.

  az network public-ip create \
    --resource-group QuickStartCreateIP-rgLB \
    --name myStandardPublicIP-zonal \
    --version IPv4 \
    --sku Standard \
    --zone 2

Note

The above options for zones are only valid selections in regions with Availability Zones.

Clean up resources

If you're not going to continue to use this application, delete the public IP address with the following steps:

  1. In the search box at the top of the portal, enter Resource group.

  2. In the search results, select Resource groups.

  3. Select QuickStartCreateIP-rg.

  4. Select Delete resource group.

  5. Enter QuickStartCreateIP-rg for TYPE THE RESOURCE GROUP NAME and select Delete.

Next steps

Advance to the next article to learn how to create a public IP prefix: