Hi,
Inside of your VM, it should always use private IP, assigned via DHCP in majority of cases. If you need the private IP to be static you set this on the Azure network interface. This is how Azure networking works.
You associate the public IP address with the Azure network interface.
Associate a public IP address to a virtual machine
Are you using Azure Virtual Desktop (AVD) service? Generally you don't assign public IP address to a VM that is used for AVD, but you may have some sort of special requirement.
Please click Accept Answer and upvote if the above was helpful.
Thanks.
-TP