Azure Documentation

Azure CLI Network Public IP Addresses

This document provides comprehensive reference information for managing Azure Public IP addresses using the Azure Command-Line Interface (CLI).

Overview

Public IP addresses are essential for exposing your Azure resources to the internet. The Azure CLI provides powerful commands to create, configure, and manage these IP addresses. This section covers common operations and parameters.

Core Commands

The primary commands for managing Public IP addresses are found under the az network public-ip group.

Creating a Public IP Address

Use the az network public-ip create command to provision a new public IP address resource.

az network public-ip create \
    --resource-group MyResourceGroup \
    --name MyPublicIP \
    --allocation-method Static \
    --sku Standard \
    --location eastus

Parameters:

Listing Public IP Addresses

Retrieve a list of all public IP addresses within a resource group or across your subscription.

az network public-ip list --resource-group MyResourceGroup
az network public-ip list

Showing Public IP Address Details

Get detailed information about a specific public IP address.

az network public-ip show --resource-group MyResourceGroup --name MyPublicIP

Updating a Public IP Address

Modify properties of an existing public IP address. Common updates include changing tags or association with other resources.

Note: Some properties like allocation-method and sku cannot be directly updated after creation and may require deletion and re-creation of the public IP address.
az network public-ip update --resource-group MyResourceGroup --name MyPublicIP --tags environment=production

Deleting a Public IP Address

Remove a public IP address resource. Ensure it is not associated with any active resources (e.g., VMs, Load Balancers) before deletion.

az network public-ip delete --resource-group MyResourceGroup --name MyPublicIP

Common Configurations

Associating with a Virtual Machine

Public IP addresses are commonly associated with network interfaces (NICs) of virtual machines to provide internet connectivity.

First, create a NIC:

az network nic create \
    --resource-group MyResourceGroup \
    --name MyVMNic \
    --vnet-name MyVNet \
    --subnet MySubnet \
    --public-ip-address MyPublicIP

Associating with a Load Balancer Frontend IP Configuration

You can assign a public IP address to the frontend configuration of an Azure Load Balancer.

az network lb frontend-ip create \
    --resource-group MyResourceGroup \
    --lb-name MyLoadBalancer \
    --name MyFrontendIP \
    --public-ip-address MyPublicIP

IP Address SKU Comparison

Feature Basic SKU Standard SKU
Allocation Method Dynamic, Static Dynamic, Static
Availability Zone Support No Yes (Zone-redundant, Zonal)
IP Routing Basic Standard (allows NSG association)
Associated Resource Types VMs, App Services, Load Balancers, etc. VMs, App Services, Load Balancers, Bastion, AKS, etc.
Default Idle Timeout 4 minutes (Dynamic) 4 minutes (Dynamic), 0 (Static)

Next Steps

Explore related networking concepts: