'Get Azure FQDN (DNS Name) by Public IP Address

To get the FQDN for the VM I can do it with -VMName like:

$vm = Get-AzVM -VMName "name"
$pubip = Get-AzPublicIpAddress -ResourceGroupName $vm.ResourceGroupName | where{$_.Id -match $vm.Name}

$pubip.DnsSettings.Fqdn

But I want to do this with the local IP like (so no manual input neccessary):

$vm = Get-AzVM -IP "20.X.X.15"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source