If i assume what you're trying to achieve;
You have a virtual machine, with a Static Public IP Address. You're trying to either;
- Use a new, different IP address for the VM
- Change the IP address to be dynamically allocated.
In either case, you should simply create a new Public IP address of the correct specification then allocate it to the NIC of the Virtual Machine. In the case of wanting a dynamic address ensure you create a Basic SKU Public IP (please be aware that Basic SKU Public IP is on a deprecation path).
For more information on Public IP addresses in Azure, see: https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/public-ip-addresses#ip-address-assignment