Date posted: 13 Jan 2019, 1 minutes to read

Missing Azure Functions Logs

I was testing with our Azure Function and had set the cron expression on the timer trigger to "0 0 */2 * * *", based on the example from the Microsoft documentation. When I went to the logs a day later, I noticed that some of the runs weren’t there! unsplash-logoPhoto by Emily Morter

Missing logs ??

I added a red line were I noticed some of the logs missing.

At first, I thought that the trigger wasn’t firing, or maybe something was wrong with my cron expression. I tested several other expressions and redeployed the function, but to no avail.

Eventually, I found a comment deep down in a GitHub issue that actually pointed me in the right direction!

Application Insights Sampling

The logs you see in an Azure function are provided by Application Insights. Due to large data ingestion during our testing period (we had the trigger fire every minute to test with), I had enabled sampling on the Application Insights instance! That change was made after seeing a bill going upwards of € 500,- during the testing period 😄.

Finding the sampling setting

To correct the sampling settings (running once every two hours is significantly less data then every minute!), you need to go to the Application Insights instance.

Go to Usage and estimated costs and click on the data sampling button:

You can now change the sampling setting:

Wait for a couple of runs to execute and you can verify that it now shows all the logs again: