Script to reserve the Public IP while resize the VM

Veerpal Singh 31 Reputation points
2022-02-20T19:10:59.19+00:00

Script to Reserve the Public IP address while resizing the VM

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,387 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. suvasara-MSFT 10,041 Reputation points
    2022-02-21T04:28:29.23+00:00

    anonymous user , From your question it looks like you have a basic sku PIP in dynamic state. here is a CLI command to turn dynamic PIP to static.

    CLI:

       az network public-ip update -g MyResourceGroup -n MyIp --dns-name MyLabel --allocation-method Static  
     
    

    PS:

       $publicIp = Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName  
         
       $publicIp.PublicIpAllocationMethod = "Static"  
             
       Set-AzPublicIpAddress -PublicIpAddress $publicIp  
         
       Get-AzPublicIpAddress -Name $publicIpName -ResourceGroupName $rgName  
    

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.