Hello there,
In this article, you learn how to associate a public IP address to an existing virtual machine (VM). To do so, you associate the public IP address to an IP configuration of a network interface attached to a VM. You can use the Azure portal, the Azure CLI, or Azure PowerShell.
If you want to instead create a new VM with a public IP address, you can use the Azure portal, the Azure CLI, or Azure PowerShell.
https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/associate-public-ip-address-vm
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--