Public IP Addresses in Azure
A public IP address is a resource that is associated with a virtual machine, load balancer, or other Azure resource to provide connectivity from the internet to that resource.
Understanding Public IP Addresses
Public IP addresses allow resources in Azure to communicate with the internet and allow the internet to communicate with those resources. They are assigned from a pool of Azure-owned IP address ranges. You can have either dynamic or static public IP addresses.
Types of Public IP Addresses
- Dynamic: When a resource is started or deallocated and then restarted, the dynamic IP address may change.
- Static: A static IP address is assigned to a resource and remains assigned until the resource is deleted.
SKUs for Public IP Addresses
Azure offers two SKUs for public IP addresses, each with different capabilities and features:
- Basic: Provides essential public IP functionality. Resources using the Basic SKU are not guaranteed to retain their IP address if they are deallocated.
- Standard: Offers advanced features, including zone redundancy, tighter security controls (Network Security Groups), and guaranteed IP address retention. Recommended for most production workloads.
Key Features and Benefits
- Global Reach: Access your resources from anywhere in the world.
- Scalability: Easily manage and scale your IP address allocation.
- Security: Integrate with Network Security Groups (NSGs) for granular access control.
- High Availability: Standard SKU offers zone redundancy for critical applications.
Common Scenarios
- Assigning a public IP to a virtual machine to access it remotely (e.g., RDP, SSH).
- Associating a public IP with an Azure Load Balancer to distribute incoming internet traffic across multiple VMs.
- Using public IPs for Azure Application Gateway for web application traffic management.
Pricing
The cost of public IP addresses depends on the SKU (Basic or Standard) and whether the IP address is associated with a running resource or is idle. Static IP addresses that are not associated with a running resource may incur charges.
Creating a Public IP Address
You can create a public IP address using the Azure portal, Azure CLI, Azure PowerShell, or ARM templates.
Azure CLI Example (Standard SKU, Static Assignment)
az network public-ip create \
--resource-group MyResourceGroup \
--name MyPublicIP \
--allocation-method Static \
--sku Standard \
--location eastus
Azure PowerShell Example (Basic SKU, Dynamic Assignment)
New-AzPublicIpAddress -Name "MyBasicPublicIP" -ResourceGroupName "MyResourceGroup" -Location "eastus" -AllocationMethod Dynamic -Sku Basic
Managing Public IP Addresses
You can view, associate, disassociate, and delete public IP addresses through the Azure portal or management tools. When associating a public IP with a resource like a virtual machine, you typically do so during the resource creation process or by updating the resource's network interface.