How to configure Azure Function access restrictions to allow for testing via portal

Viewed 1519

I've got my Azure function app set to restrict access to just the APIM public IP and my desktop IP. I seem though to be unable to test the function within the portal itself (i.e. going to MyFunctionAppName > TestFunction > Code + Test > Test/Run) as I get an error saying "You must have direct network access in order to run your function. Your app may be restricted with Private Endpoints, Access Restrictions or Service Endpoints." I'm not sure if there's an IP I need to add or something else to let me test via the portal itself.

2 Answers

it means that Test/Run button sends test request from server side (Azure) - at least it would explain why request comes not from your IP address but from Azure (if it would send request from client side - request would come from your IP address). So your workaround with adding Azure IP to white list looks correct

This answer may help you, please refer to this question.

I was struggling with the same thing after adding VNets. The issue is as mentioned earlier that the requests originate from an Azure IP, a list of them can be found here. As you can see from the link, it's a lot of possible IPs and they frequently change. What I found however is that you can now whitelist a Service Tag named AzureCloud. This whitelists all datacenter public IPs, which will allow you to use the Test/Run feature through the Azure Portal again.

Related