Azure Function Monitoring

How To Monitor Azure Functions

In this Azure tutorial, we will discuss Azure Functions monitoring options and steps to configure.

Monitor Azure Functions

Well, here we will discuss How to monitor Azure Functions. We must always have the option to monitor your Azure Functions. Azure Function provides an excellent option to integrate your Azure Function with the Azure Monitor logs.

If you try to understand the Azure Monitor Logs, Azure Monitor Logs is a feature of the Azure Monitor that collects from different sources, and you can analyze those data whenever needed.

Another important thing is Azure Monitor Logs is based on the Azure Data Explorer. You must query the Log details using the Kusto Query Language (KQL). Azure Monitor Logs collects the data and stores it in a Log Analytics workspace that consists of multiple tables, and each table contains the log data from a specific source.

Depending on your requirement, either you can use a single workspace, or you can use multiple workspaces for your Log data. You can also configure to store the Application Insights log data in the Azure Monitor logs. Multiple Applications can also use the same workspace.

You can use the Log Analytics Tool in the Azure Portal to interactively analyze the logs.

How To Configure Azure Monitor Logs For The Azure Function

You can follow the below steps to configure Azure Monitor Logs For the Azure Function. But the first thing we need is to create a Log Analytics workspace for configuring the Log Analytics workspace.

Create a Log Analytics workspace in the Azure portal

Follow the below steps to create a Log Analytics workspace in the Azure portal.

  1. Log in to the Azure Portal (
  2. Once you log in to the Azure Portal, search for the Log Analytics workspace and click on the search result

3. Now, on the Log Analytics workspaces page, click the + Add button.

monitor azure functions

4. On the Create Log Analytics Workspace, Provide the below details

  • Subscription: Choose your correct subscription
  • Resource group: Select your existing Resource group. If you don’t have any existing Resource Group, click on the Create new link to create the Resource group.
  • Name: Provide a unique name.
  • Region: Choose the location for the Log Analytics Workspace.

You can keep the other tabs option as default and click the Review + Create button.

Azure Function Monitor

5. Now, on the next screen, It will validate the Information Provided by you and show you the Validation passed, and then you click on the create button to create the Log Analytics workspace.

azure function console

6. Now, it will show you that Your deployment is complete. Click the Go to Resource button to see the Log Analytics Workspace you created.

azure functions logging without application insights

You can see below the Log Analytics Workspace that we have created just now

How To Monitor Azure Functions

Configure Azure Monitor Logs For The Azure Function

Now that our Log Analytics workspace is ready, We need to configure the Azure Monitor Logs.

  1. Log in to the Azure Portal (
  2. Navigate to the Azure Function App for the one you want to configure the Azure Monitor Logs
functions monitoring

3. The next step is to click on the Diagnostic settings (Preview) option and then click on the + Add diagnostic setting as highlighted below.

azure function monitor

4. On the Diagnostics setting page, Provide a name for the Diagnostic settings, then select the FunctionAppLogs and Send to Log Analytics option. Once you select the Send to Log Analytics option, You can see the Subscription and Log Analytics workspace options. Please choose the correct Subscription for you, and For the Log Analytics workspace option, choose the Log Analytics workspace we have created above.

5. Finally, click on the Save button.

azure function console log

6. Now again, if you navigate the Azure Function App and click on the Diagnostic settings (Preview) option, you can see that it has been successfully created, as highlighted below.

azure function app monitoring

Query the logs

Now, to query the logs that are generated, you need to follow the below steps

  • Navigate to the Azure Function App. From the left navigation, click on the Diagnostic settings (preview) and click on the Log Analytics workspace that you configured just before.
azure monitor
  • From the Log Analytics workspace page, click on the Logs from the left navigation, and you can see the FunctionAppLogs table as highlighted below. Azure Functions writes all logs to the FunctionAppLogs table.
monitoring azure functions
  • You can write the query in the Query window and click on the Run button to execute the Query, or you can double-click on the FunctionAppLogs and click on the Run button. If you want to retrieve the log details for the specific Azure Function, paste the query below in the Query window and click on the Run button.
| where FunctionName == "YourAzureFunctionName"
  • You can also get the complete log details using the below query.
| order by TimeGenerated desc
  • You can see it here
azure monitor functions

Check out Azure Function Logging

Azure Function Console Log

When working with the Azure Function in Visual Studio, Once you create the Azure Function, if you closely look at the Function code, you can see that the ILogger injected into your Function can be used for the logging functionality.

When you press F5 to run the Azure Function locally, you will notice that this logger will display the messages in the console window of your Visual Studio IDE.

But, Once you deploy the Azure Function to the Azure, You will not see the Visual Studio console window, which is obvious. So, at that time, you need to connect to the Azure Application Insight to your Azure Function to capture these logs.

Azure Function ilogger Application Insights

While working with the Azure function, it’s a great idea to implement logging to track what’s going on with the Azure function. For that, we need to enable the Application insights for the Azure Function, and in this case, with the use of the iLogger interface, we can send the logs to the application insights.

How to Configure Application Insights Logging

As we know, Application Insights is an excellent option to store your logs related to exceptions, Information, etc. So, configuring the Application Insights option for your Azure Function is always a great idea. So, Configure the Azure Application Insight for your Azure Function now.

In Built Report

The inbuilt performance report for your Azure Function looks great, with some key information like the one below. It provides a report on the key factors

  • The Azure Function Instance processes the Successful and failed requests.
  • How many exceptions exactly have been thrown with the Azure Functions?
  • The resources allocated to your Azure Functions.

The default performance reports for Azure Functions are quite good for real-time performance monitoring, even locally. It gives a great view of:

  • the resources allocated to the Functions;
  • how many successful and failed requests have been processed by the Function instance
  • how many exceptions have been thrown
  • The overall health of your Azure Function.
azure functions application insights logging

Build Your Custom Reports

If you are still unhappy with the Built-in Reports, you can build your Custom Reports with the Additional information based on your requirements. You can use different queires to build custom reports based on your business needs.

By enabling application insights without any further add-ons, we get all the logs sent to the ILogger object to application Insights. We also get some End-To-End tracking via supported SDK’s and HttpClient requests. This is very useful to get an understanding of what is happening. So, let’s look into how this manifests in a rather complex scenario.

You may also like following the articles below

Wrapping Up

In this article, we discussed the steps to monitor Azure Functions. I hope you have enjoyed this article !!!