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.
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.
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.
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With