Categories
Azure

How to query multiple Azure Application Insights instances at once

Do you have multiple Azure Application Insights instances that you’d like to query at once? Perhaps you’re trying to see all errors across multiple environments, each with their own App Insights instance?

When using the Azure Portal, querying multiple instances is straightforward.

How to query across multiple App Insight instances

First, login to the Azure portal using your Microsoft work, school or personal account credentials.

Navigate to one of the App Insight instances you’d like to run a query against.

Then, in the sidebar scroll down until you see ‘Logs’. Click on this menu item.

Application Insights logging screen

You should now see the Application Insights query screen. From here, click ‘Select scope’.

Application Insights scope selector

A new modal will appear, allowing you to select multiple Application Insights instances to run your query against from through out your subscription and across multiple resource groups.

Once you’ve clicked the checkbox next to your selected Application Insights instances, click ‘Apply’ to close the modal and persist your selection.

Now type your query, and click ‘Run’. It will execute the request against all your selected scopes (in this case your Application Insights instances) and return the results.

Categories
Azure Azure Functions

How to add Application Insights to an Azure function

Today we’re going to look at how easy it is to add Azure Application Insights (part of Azure Monitor) to an Azure Function.

What is Application Insights?

In short, Application Insights is a performance and monitoring tool that forms part of the Azure Monitor suite. It allows you to access detailed telemetry on requests made to your function, while observing real-time performance and failures. It works across App Service apps, Azure Functions and more – practically anywhere you can install the available App Insights SDKs.

You can find the full pricing information here, but you effectively get charged per GB of ingested data (5GB included free per month).

How can I enable this for my Azure Function App?

For Azure Functions, it’s super simple to enable App Insights. You don’t even need to add the SDKs – Microsoft handles that for you.

First, you’ll need to create an Application Insights instance. Open the Azure Portal, click “Create a resource” and search for “Application Insights”.

Enter a friendly and unique name for your instance, and depending on the language you write your functions in, choose General or Node.js for the “Application Type”.

Choose a subscription and resource group (ideally matching those of your Azure Function app) and a location. Note that App Insights is only supported in a limited number of regions worldwide, so you might need to choose a different region to that of your functions app.

Once that’s been created, open the App Insights resource. On the “Overview” page, you’ll see in the top section an “Instrumentation Key”. Copy this – it’s essentially the identifier that will allow you function app to report data back into this App Insights resource.

Now navigate to your function app in the Azure Portal. Select the app name in the sidebar, and choose “Platform Features” on the right-hand side of the screen.

Next, open “Application settings”. Scroll down until you see the “Application settings” header. At the bottom of this section, you’ll see a “Add new setting” button – click this to add a new row.

Now in the “App Setting Name” column, type “APPINSIGHTS_INSTRUMENTATIONKEY”. In the “Value” column, paste the “Instrumentation Key” that we copied in the earlier step from your App Insights resource. Scroll back to the top of the page, and click “Save”.

Summary

And that’s it! That’s how easy it is to enable App Insights for Azure Functions. If you want to see metrics coming through straight away, navigate to your App Insights resource and click “Live Metrics”. Make an API request to your function (assuming it’s HTTP based – otherwise trigger it however you can) and you should see the request come through instantly.