The error message "Name or service not known" typically indicates that the hostname you are trying to connect to cannot be resolved by the DNS server.
Here are a few possible causes for this issue when making an HTTPS call to an APIM instance from an Azure Function:
- The Azure Function is not in the same virtual network as the APIM instance: Make sure that the Azure Function and APIM instances are in the same VNET and subnet.
- The service endpoint for the Microsoft.ApiManagement service is not configured: Make sure that the Azure Function has been granted access to the APIM subnet by creating a service endpoint for the Microsoft.ApiManagement service.
- The Azure Function's IP address is not in the list of allowed IP addresses in the APIM configuration: Make sure that the Azure Function has been granted access to the APIM instance by adding its IP address to the list of allowed IP addresses in the APIM configuration.
- The Azure Function is not using the internal URL of the APIM: Make sure that the Azure Function is calling the internal URL of the APIM, which can be found under the "Networking" tab of the APIM instance in the Azure Portal.
- The private endpoint for the APIM instance is not created: Make sure that you have created a private endpoint for the APIM instance in the same VNet and subnet of the Azure Function.
- The DNS server of the VNET is not configured to resolve the APIM's hostname: Make sure that the DNS server of the VNET is configured to resolve the hostname of the APIM instance.
You can check the Azure function's application logs for more information about the error. Also, you can try to use the FQDN of the APIM instance instead of the hostname to see if it resolves the issue.