You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Integrate Azure API Management with Azure Application Insights
2
+
title: Integrate Azure API Management with Application Insights
3
3
titleSuffix: Azure API Management
4
4
description: Learn how to log and view events from Azure API Management in Azure Application Insights.
5
-
services: api-management
6
5
author: dlepow
7
6
8
7
ms.service: api-management
9
-
ms.tgt_pltfrm: na
10
8
ms.topic: how-to
11
-
ms.date: 06/02/2023
9
+
ms.date: 08/25/2023
12
10
ms.author: danlep
13
11
ms.custom: engagement-fy23
14
-
15
12
---
16
13
17
14
# How to integrate Azure API Management with Azure Application Insights
18
15
19
16
You can easily integrate Azure Application Insights with Azure API Management. Azure Application Insights is an extensible service for web developers building and managing apps on multiple platforms. In this guide, you will:
20
-
* Walk through every step of the Application Insights integration into API Management.
17
+
* Walk through Application Insights integration into API Management.
21
18
* Learn strategies for reducing performance impact on your API Management service instance.
22
19
23
20
## Prerequisites
24
21
25
-
You need an Azure API Management instance. [Create one](get-started-create-service-instance.md) first.
26
-
27
-
## Create an Application Insights instance
22
+
* You need an Azure API Management instance. [Create one](get-started-create-service-instance.md) first.
28
23
29
-
To use Application Insights, [create an instance of the Application Insights service](/previous-versions/azure/azure-monitor/app/create-new-resource). To create an instance using the Azure portal, see [Workspace-based Application Insights resources](../azure-monitor/app/create-workspace-resource.md).
24
+
*To use Application Insights, [create an instance of the Application Insights service](/previous-versions/azure/azure-monitor/app/create-new-resource). To create an instance using the Azure portal, see [Workspace-based Application Insights resources](../azure-monitor/app/create-workspace-resource.md).
30
25
31
26
> [!NOTE]
32
27
> The Application Insights resource **can be** in a different subscription or even a different tenant than the API Management resource.
33
28
34
-
## Create a connection between Application Insights and API Management
29
+
## Scenario overview
35
30
36
-
> [!NOTE]
37
-
> If your Application Insights resource is in a different tenant, then you will have to create the logger using the [REST API](/rest/api/apimanagement/current-ga/logger/create-or-update)
31
+
1. First, you create a connection between Application Insights and API Management
32
+
33
+
You can create a connection between Application Insights and your API Management using the Azure portal, the REST API, or related Azure tools. API Management configures a *logger* resource for the connection.
34
+
35
+
> [!NOTE]
36
+
> If your Application Insights resource is in a different tenant, then you must create the logger using the [REST API](/rest/api/apimanagement/current-ga/logger/create-or-update).
37
+
38
+
> [!IMPORTANT]
39
+
> Currently, in the portal, API Management only supports connections to Application Insights using an Application Insights instrumentation key. To use an Application Insights connection string or an API Management managed identity, use the REST API, Bicep, or ARM template to create the logger.
40
+
>
41
+
42
+
1. Second, you enable Application Insights logging for your API or APIs.
43
+
44
+
In this article, you enable Application Insights logging for your API using the Azure portal. API Management configures a *diagnostic* resource for the API.
45
+
46
+
47
+
## Create a connection using the Azure portal
48
+
49
+
Follow these steps to use the Azure portal to create a connection between Application Insights and API Management.
38
50
39
51
1. Navigate to your **Azure API Management service instance** in the **Azure portal**.
40
52
1. Select **Application Insights** from the menu on the left.
@@ -49,11 +61,206 @@ To use Application Insights, [create an instance of the Application Insights ser
49
61
:::image type="content" source="media/api-management-howto-app-insights/apim-app-insights-logger-2.png" alt-text="Screenshot that shows where to view the newly created Application Insights logger.":::
50
62
51
63
> [!NOTE]
52
-
> Behind the scenes, a [Logger](/rest/api/apimanagement/current-ga/logger/create-or-update) entity is created in your API Management instance, containing the instrumentation key of the Application Insights instance.
64
+
> Behind the scenes, a [logger](/rest/api/apimanagement/current-ga/logger/create-or-update) entity is created in your API Management instance, containing the instrumentation key of the Application Insights instance.
53
65
54
66
> [!TIP]
55
67
> If you need to update the instrumentation key configured in the Application Insights logger, select the logger's row in the list (not the name of the logger). Enter the instrumentation key, and select **Save**.
56
68
69
+
## Create a connection using the REST API, Bicep, or ARM template
70
+
71
+
Follow these steps to use the REST API, Bicep, or ARM template to create a connection between Application Insights and API Management. You can configure a logger that uses a connection string, system-assigned identity, or user-assigned identity.
72
+
73
+
The following prerequisites are needed to configure a managed identity for API Management:
74
+
75
+
1. Enable a system-assigned or user-assigned [managed identity for API Management](api-management-howto-use-managed-service-identity.md) in your API Management instance.
76
+
77
+
* If you enable a user-assigned managed identity, take note of the identity's **Client ID**.
78
+
79
+
1. Assign the identity the **Monitoring Metrics Publisher** role, scoped to the Application Insights resource. To assign the role, use the [Azure portal](../active-directory/managed-identities-azure-resources/howto-assign-access-portal.md) or other Azure tools.
80
+
81
+
82
+
### Logger with connection string credentials
83
+
84
+
Your connection string appears in the **Overview** section of your Application Insights resource.
85
+
86
+
#### [REST API](#tab/rest)
87
+
88
+
Use the API Management [REST API](/rest/api/apimanagement/current-preview/logger/create-or-update) with the following request body.
89
+
90
+
```JSON
91
+
{
92
+
"properties": {
93
+
"loggerType": "applicationInsights",
94
+
"description": "adding a new logger with connection string",
0 commit comments