However, in the Azure CLI, this list isn't grouped into regions. The location doesn't affect the list in any way and there are no subsections for AzureIoTHub (like e.g. "AzureCloud.westeurope" for AzureCloud).
The only way I see to get the AzureIoTHub ranges for the westeurope region is to download and parse the list rather than using the CLI, which is a bit cumbersome.
Do you have any ideas on how to get the appropriate list programmatically (rather than downloading files from arbitrary URLs)?
I tried it myself and the discovery API is not returning the AzureIoTHub service tag by region. Like mentioned here: "Note that the service tags discovery API is still in preview and, in some cases, may not produce the full list of tags and IP addresses. Until the discovery API is generally available, consider using service tags in downloadable JSON format."
Looks like downloading the JSON file is the way to go...