Search code examples
azureazure-functionsazure-web-app-serviceazure-virtual-networkprivate-subnet

Azure function app with private endpoint on time trigger - manual trigger is not working


Azure function app with private endpoint on time trigger - manual trigger is not working

An Error 403 occurs when triggering the function app manually, scheduled triggering is working. The function app has private endpoints and is reachable from on-premise. <h1 id="unavailable">Error 403 - Forbidden</h1> <p id="tryAgain">The web app you have attempted to reach has blocked your access.</p> The function app can be manually triggered from a vm within the same network: no error occurs on the vm, but the logs don't show any activity.

curl -X POST -H "Content-Type application/json" "https://<appname>.azurewebsites.net/api/<appname>/<functionkey>"

Microsoft says this is expected behavior when using private endpoints, but at least the vm within the same vnet should trigger? Any thoughts are appreciated.

An Error 403 occurs when triggering the function app manually, scheduled triggering is working. The function app has private endpoints and is reachable from on-premise. <h1 id="unavailable">Error 403 - Forbidden</h1> <p id="tryAgain">The web app you have attempted to reach has blocked your access.</p> The function app can be manually triggered from a vm within the same network: no error occurs on the vm, but the logs don't show any activity.

curl -X POST -H "Content-Type application/json" "https://<appname>.azurewebsites.net/api/<appname>/<functionkey>"

Solution

  • I tried the same in my environment created Azure function app with private endpoint like below:

    enter image description here

    Under networking added private endpoint:

    enter image description here

    Make sure to add Vnet integration try to add same virtual network associated with VM like below:

    ![enter image description here](https://i.imgur.com/tZTmaef.png)
    

    Now in function app when I try to trigger manually, it triggered successfully like below:

    enter image description here

    The function app is reachable from on-premises with private endpoint network like below:

    enter image description here

    enter image description here

    To get logs and activity check the below:

    curl -X POST -H "Content-Type application/json" "https://<appname>.azurewebsites.net/api/<appname>/<functionkey>"
    

    enter image description here

    In your function app -> logs -> type requests you will be able to see the log and activity of status like below:

    enter image description here

    You can make use of diagnostic setting:

    In function app -> diagnostic setting selects the destination for your logs and metrics. You can route it to either Azure Monitor, Event Hubs, Log Analytics workspace, or Storage account like below.

    You may configure the collection and transmission of logs and metrics from your Azure Function app to various monitoring and analytics services using the diagnostic settings for Azure Function.

    enter image description here

    While using virtual network ensure Service endpoints is enabled. As a result, your function app may securely access these services without depending to rely on public endpoints.

    Check the Access restrictions in this GitHub blog by ggailey.