Run with PowerShell 7.4 or later based on .NET 8 which includes the new IPNetwork type. Requires authenticated Azure CLI.
# e.g. ns-sb2-prod-am3-002.cloudapp.net (service bus namespace in westeurope)
$ip=[net.ipaddress]::parse("104.46.32.56")
az network list-service-tags --location westeurope | `
convertfrom-json | `
select -exp values -pv st | `
%{$_.properties.addressprefixes | `
%{[pscustomobject]@{Name=$st.name;AddressPrefix=$_}}
} | `
?{[net.ipnetwork]::parse($_.addressprefix).contains($ip)} | `
ft -auto
Example result for 104.46.32.56
resolved from A record ns-sb2-prod-am3-002.cloudapp.net
for Service Bus namespace in West Europe.
This result shows that as of November 2023 Azure service tags are incorrect, since the IP address should be included in ServiceBus.WestEurope
,
but it is only included in the more general AzureCloud and related EventHub service tags.
Name AddressPrefix
---- -------------
AzureCloud 104.46.32.0/19
AzureCloud.westeurope 104.46.32.0/19
EventHub 104.46.32.56/32
EventHub.WestEurope 104.46.32.56/32