Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure function apps logs not showing

I'm relatively new to Azure and I just went through the tutorial on how to create a new Azure function, which is triggered when a new blob is created, and had this as the default code in it.

public static void Run(Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}

From what I can see on the tutorial, I should be able to see some information in the "logs" area below the code, but nothing shows up, I've been checking for a solution for a while now but can't seem to find anything useful.

Any help would be greatly appreciated.

like image 474
Kikanye Avatar asked Jun 20 '17 15:06

Kikanye


People also ask

How do I view logs in Azure function app?

While running the Azure Function, you can see the File System Logs in the Logs Console of the Test/Run Page or Log Stream under Monitoring in the left index menu of the Function App.

How do I enable Azure function logs?

To turn on the streaming logs for your function app in Azure: Select F1 to open the command palette, and then search for and run the command Azure Functions: Start Streaming Logs. Select your function app in Azure, and then select Yes to enable application logging for the function app. Trigger your functions in Azure.

How do I enable Application insights in Azure?

In your function app, select Configuration under Settings, and then select Application settings. If you see a setting named APPINSIGHTS_INSTRUMENTATIONKEY , Application Insights integration is enabled for your function app running in Azure.


4 Answers

The log window is a bit fragile and doesn't always show the logs. However, logs are also written to the log files.

You can access these logs from the Kudu console: https://[your-function-app].scm.azurewebsites.net/

From the menu, select Debug console > CMD

On the list of files, go into LogFiles > Application > Functions > Function > [Name of your function]

There you will see a list of log files.

like image 133
Cloud SME Avatar answered Oct 21 '22 04:10

Cloud SME


Following the advice here worked for me. Configuring Log Level for Azure Functions

If you want to see your logs show up immediately in the Portal console after you press "Run", then go to your "Function app settings" and add the following to your host.json file:

"logging": {
    "fileLoggingMode": "always",
    "logLevel": {
        "default": "Information",
        "Host.Results": "Error",
        "Function": "Trace",
        "Host.Aggregator": "Trace"
    }
}

Note that this only worked for Javascript functions. For locally developed functions in other languages, the console can be a bit skittish.

like image 21
James Shapiro Avatar answered Oct 21 '22 02:10

James Shapiro


Microsoft keep changing the interface so many of these answers no longer are correct.

The best way I have found to view the logs is to go into Application Insights for the function itself and then search for some text that might be in the log in Transaction search.

like image 8
Matthew Avatar answered Oct 21 '22 03:10

Matthew


Azure Portal was updated last week and they moved logs from Monitor to the home of the actual Azure Function. However, to see them you need to click Test. I raised an issue with Microsoft support and they spent several days twiddling their thumbs before I came across the answer myself. I hope this saves others a bit of time

enter image description here

like image 7
wpqs Avatar answered Oct 21 '22 02:10

wpqs