Solution:
Create a Storage Account which is not in the same region as your function app. For example, if your Function is in Central US
, the Storage Account should select a different one like East US
. Then modify the following three parameters(in Application settings) with new created Storage Account Connection String.
- AzureWebJobsDashboard
- AzureWebJobsStorage
- WEBSITE_CONTENTAZUREFILECONNECTIONSTRING (only used for Consumption plan)
Configure its Firewall with Function app outbound IP addresses.
On Platform features panel of your Function app, click Resource Explorer.
Find outboundIpAddresses and add all of them to Firewall IP list.
Don't forget to add your local IP if you want to visit Storage Account using Azure Portal. (Not necessary for deployment from VS).
Explanation:
Can only reproduce the INSUFFICIENT_ACCESS for a Function hosted on Consumption plan.
About this problem, the biggest difference between App service and Consumption plan is how they host function files.
For an App service plan, function files we publish or create on portal are stored on some Azure server. Adding firewall settings to Storage Account used by AzureWebJobsDashboard
(store function logs in tables) and AzureWebJobsStorage
(store function host locks in container), has no influence on function deployment.
While for Consumption plan, function files are stored on the Storage Account specified by WEBSITE_CONTENTAZUREFILECONNECTIONSTRING
. When we publish from VS or create functions on portal, function files are deployed from function site to Storage Account. We met the error as we don't add function app IPs to Storage firewall white list.
As for why we have to create the Storage in a region different from Function app's, based on my tests, function seems not leverage the outbound IPs when they two locate at the same region. See some one on GitHub got the same result.