Set-AzPublicIpAddress

Updates a public IP address.

Syntax

Set-AzPublicIpAddress
   -PublicIpAddress <PSPublicIpAddress>
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The Set-AzPublicIpAddress cmdlet updates a public IP address.

Examples

1: Change allocation method of a public IP address

PS C:\> $publicIp = Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName

PS C:\> $publicIp.PublicIpAllocationMethod = "Static"
    
PS C:\> Set-AzPublicIpAddress -PublicIpAddress $publicIp

PS C:\> Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName

First command gets the public IP address resource with name $publicIPName in the resource group $rgName. Second command sets the allocation method of the public IP address object to "Static". Set-AzPublicIPAddress command updates the public IP address resource with the updated object, and modifies the allocation method to 'Static'. A public IP address gets allocated immediately.

2: Change DNS domain label of a public IP address

PS C:\> $publicIp = Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName

PS C:\> $publicIp.DnsSettings.DomainNameLabel = "newdnsprefix"
    
PS C:\> Set-AzPublicIpAddress -PublicIpAddress $publicIp

PS C:\> $publicIp = Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName

First command gets the public IP address resource with name $publicIPName in the resource group $rgName. Second command sets the DomainNameLabel property to the required dns prefix. Set-AzPublicIPAddress command updates the public IP address resource with the updated object. DomainNameLabel & Fqdn are modified as expected.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PublicIpAddress

Specifies a public IP address object representing the state to which the public IP address should be set.

Type:PSPublicIpAddress
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Inputs

PSPublicIpAddress

Outputs

PSPublicIpAddress