In some scenario, you may want to assign static ip to Azure VM especially domain controller/ DNS VM or plan to stop at some point but retain the ip address for a particular VM. Here is step that may help to configure static IP address to Azure VM.
List down azure VM on your subscription. Type “Get-AzureVM”
Verify that a specific IP address is available before assign. Use cmdlet:- Test-AzureStaticVNetIP
|Test-AzureStaticVNetIP –VNetName AzureVnet –IPAddress 10.0.1.4|
Assign Static IP to a VM that you previously created. Update-AzureVM cmdlets restart the VM as part of the update process.
|Get-AzureVM -ServiceName "MLABDC1" -Name "MLABDC1" | Set-AzureStaticVNetIP -IPAddress 10.0.1.4 | Update-AzureVM|
To Remove a Static IP. If you would like to change another ip address, you need to execute below cmdlet to remove it first.
|Get-AzureVM –ServiceName :MLABDC1” –Name “MLABDC1” | Remove-AzureStaticVNetIP | Update-AzureVM|
VM will automatically get a new Dynamic IP Address after the VM restart as part of the update process.