azureazure-functionsazure-application-insightsazure-powershellazure-function-app

Where to find the App Service Logs for a Http Trigger Function written in Powershell?


In Azure I create a Function App with Powershell Core Runtime stack:

screenshot 1

Then I add an Http Trigger with the following code:

using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request XXX."

Then I go to Code + Test, Test/Run and click the Run button.

In the Output field on the right side I see the HTTP response content.

But the Logs field at the bottom only shows

Connecting to Application Insights...

screenshot 2

I have tried to navigating to the Logs in the left menu, but the App Service logs entry is disabled there:

This feature is not available for Function apps. Please use Application Insights.

screenshot 3

So I try following the advice and got to the Application Insights, but can not find my trace there -

screenshot 4

Please help me to find the trace

PowerShell HTTP trigger function processed a request XXX.

UPDATE:

I have followed the advice by Tony Ju (thanks!) and I can see some logs, but cannot find the trace line I am after yet:

screenshot 4


Solution

  • You can find the logs under Monitor. Note that there will be 5 mins delay to display the logs. And it will only show the twenty most recent function invocation traces.

    enter image description here

    You can also find the logs in the application insights directly.

    enter image description here

    Update:

    If you still can not find the logs there, you can try to restart your function to check if you can connect to Application Insights successfully.

    enter image description here

    Reference:

    Monitor Azure Functions

    Update2: Try to use the query as below. HttpTrigger1 is the function name.

    traces 
    | where operation_Name == "HttpTrigger1"
    | where timestamp > ago(24h) 
    | limit 20
    

    enter image description here

    Besides, restarting means restart the function app.

    enter image description here