Skip to content

Commit db35b70

Browse files
committed
[APIM] Loggers with managed identities - SFI
1 parent 937a63c commit db35b70

File tree

2 files changed

+122
-111
lines changed

2 files changed

+122
-111
lines changed

articles/api-management/api-management-howto-app-insights.md

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: dlepow
66

77
ms.service: azure-api-management
88
ms.topic: how-to
9-
ms.date: 07/11/2024
9+
ms.date: 09/04/2024
1010
ms.author: danlep
1111
ms.custom: engagement-fy23, devx-track-arm-template, devx-track-bicep
1212
---
@@ -20,7 +20,7 @@ You can easily integrate Azure Application Insights with Azure API Management. A
2020
* Learn strategies for reducing performance impact on your API Management service instance.
2121

2222
> [!NOTE]
23-
> In an API Management [workspace](workspaces-overview.md), a workspace owner can independently integrate Application Insights and enable Application Insights logging for the workspace's APIs. The general guidance to integrate a workspace with Application Insights is similar to the guidance for an API Management instance; however, configuration is scoped to the workspace only. Currently, you must integrate Application Insights in a workspace by configuring an instrumentation key or connection string.
23+
> In an API Management [workspace](workspaces-overview.md), a workspace owner can independently integrate Application Insights and enable Application Insights logging for the workspace's APIs. The general guidance to integrate a workspace with Application Insights is similar to the guidance for an API Management instance; however, configuration is scoped to the workspace only. Currently, you must integrate Application Insights in a workspace by configuring a connection string (recommended) or an instrumentation key.
2424
2525
> [!WARNING]
2626
> When using our [self-hosted gateway](self-hosted-gateway-overview.md), we do not guarantee all telemetry will be pushed to Azure Application Insights given it relies on [Application Insights' in-memory buffering](./../azure-monitor/app/telemetry-channels.md#built-in-telemetry-channels).
@@ -34,9 +34,9 @@ You can easily integrate Azure Application Insights with Azure API Management. A
3434
> [!NOTE]
3535
> The Application Insights resource **can be** in a different subscription or even a different tenant than the API Management resource.
3636
37-
* If you plan to configure a managed identity for API Management to use with Application Insights, you need to complete the following steps:
37+
* If you plan to configure managed identity credentials to use with Application Insights, complete the following steps:
3838

39-
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.
39+
1. Enable a system-assigned or user-assigned [managed identity for API Management](api-management-howto-use-managed-service-identity.md).
4040

4141
* If you enable a user-assigned managed identity, take note of the identity's **Client ID**.
4242

@@ -46,18 +46,18 @@ You can easily integrate Azure Application Insights with Azure API Management. A
4646

4747
The following are high level steps for this scenario.
4848

49-
1. First, you create a connection between Application Insights and API Management
49+
1. First, create a connection between Application Insights and API Management
5050

5151
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.
5252

53-
> [!NOTE]
54-
> If your Application Insights resource is in a different tenant, then you must create the logger using the [REST API](#create-a-connection-using-the-rest-api-bicep-or-arm-template) as shown in a later section of this article.
55-
5653
> [!IMPORTANT]
57-
> 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. [Learn more](../azure-monitor/app/sdk-connection-string.md) about Application Insights connection strings.
54+
> Currently, in the portal, API Management only supports connections to Application Insights using an Application Insights instrumentation key. For enhanced security, we recommend using an Application Insights connection string with an API Management managed identity. To configure a connection string with a managed identity, use the [REST API](#create-a-connection-using-the-rest-api-bicep-or-arm-template) or related tools as shown in a later section of this article. [Learn more](../azure-monitor/app/sdk-connection-string.md) about Application Insights connection strings.
5855
>
5956
60-
1. Second, you enable Application Insights logging for your API or APIs.
57+
> [!NOTE]
58+
> If your Application Insights resource is in a different tenant, then you must create the logger using the [REST API](#create-a-connection-using-the-rest-api-bicep-or-arm-template) or related tools as shown in a later section of this article.
59+
60+
1. Second, enable Application Insights logging for your API or APIs.
6161

6262
In this article, you enable Application Insights logging for your API using the Azure portal. API Management configures a *diagnostic* resource for the API.
6363

@@ -66,6 +66,10 @@ The following are high level steps for this scenario.
6666

6767
Follow these steps to use the Azure portal to create a connection between Application Insights and API Management.
6868

69+
> [!NOTE]
70+
> Where possible, Microsoft recommends using a connection string with a managed identity for enhanced security. To configure a connection string with a managed identity, use the [REST API](#create-a-connection-using-the-rest-api-bicep-or-arm-template) or related tools as shown in a later section of this article.
71+
72+
6973
1. Navigate to your **Azure API Management service instance** in the **Azure portal**.
7074
1. Select **Application Insights** from the menu on the left.
7175
1. Select **+ Add**.
@@ -87,28 +91,31 @@ Follow these steps to use the Azure portal to create a connection between Applic
8791
8892
## Create a connection using the REST API, Bicep, or ARM template
8993

90-
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 managed identity, or user-assigned managed identity.
94+
Follow these steps to use the REST API, Bicep, or ARM template to create an Application Insights logger for your API Management instance. You can configure a logger that uses a system-assigned or user-assigned managed identity with a connection string (recommended), or a logger that uses only a connection string.
95+
96+
97+
### Logger with system-assigned managed identity and connection string credentials
9198

92-
### Logger with connection string credentials
99+
See the [prerequisites](#prerequisites) for using an API Management managed identity.
93100

94101
The Application Insights connection string appears in the **Overview** section of your Application Insights resource.
95102

96103
#### [REST API](#tab/rest)
97104

98105
Use the API Management [Logger - Create or Update](/rest/api/apimanagement/current-preview/logger/create-or-update) REST API with the following request body.
99106

100-
If you are configuring the logger for a workspace, use the [Workspace Logger - Create or Update](/rest/api/apimanagement/workspace-logger/create-or-update?view=rest-apimanagement-2023-09-01-preview&preserve-view=true) REST API.
101-
102107
```JSON
103108
{
104109
"properties": {
105110
"loggerType": "applicationInsights",
106-
"description": "adding a new logger with connection string",
111+
"description": "adding a new logger with system-assigned managed identity",
107112
"credentials": {
108-
"connectionString":"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;..."
113+
"connectionString":"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
114+
"identityClientId":"SystemAssigned"
109115
}
110116
}
111117
}
118+
112119
```
113120

114121
#### [Bicep](#tab/bicep)
@@ -121,9 +128,10 @@ resource aiLoggerWithSystemAssignedIdentity 'Microsoft.ApiManagement/service/log
121128
parent: '<APIManagementInstanceName>'
122129
properties: {
123130
loggerType: 'applicationInsights'
124-
description: 'Application Insights logger with connection string'
131+
description: 'Application Insights logger with system-assigned managed identity'
125132
credentials: {
126133
connectionString: 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...'
134+
identityClientId: 'systemAssigned'
127135
}
128136
}
129137
}
@@ -140,17 +148,17 @@ Include a JSON snippet similar to the following in your Azure Resource Manager t
140148
"name": "ContosoLogger1",
141149
"properties": {
142150
"loggerType": "applicationInsights",
143-
"description": "Application Insights logger with connection string",
151+
"description": "Application Insights logger with system-assigned managed identity",
144152
"resourceId": "<ApplicationInsightsResourceID>",
145153
"credentials": {
146-
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;..."
147-
},
154+
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
155+
"identityClientId": "SystemAssigned"
156+
}
148157
}
149158
}
150159
```
151160
---
152-
153-
### Logger with system-assigned managed identity credentials
161+
### Logger with user-assigned managed identity and connection string credentials
154162

155163
See the [prerequisites](#prerequisites) for using an API Management managed identity.
156164

@@ -162,10 +170,10 @@ Use the API Management [Logger - Create or Update](/rest/api/apimanagement/curre
162170
{
163171
"properties": {
164172
"loggerType": "applicationInsights",
165-
"description": "adding a new logger with system-assigned managed identity",
173+
"description": "adding a new logger with user-assigned managed identity",
166174
"credentials": {
167175
"connectionString":"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
168-
"identityClientId":"SystemAssigned"
176+
"identityClientId":"<ClientID>"
169177
}
170178
}
171179
}
@@ -174,18 +182,18 @@ Use the API Management [Logger - Create or Update](/rest/api/apimanagement/curre
174182

175183
#### [Bicep](#tab/bicep)
176184

177-
Include a snippet similar to the following in your Bicep template.
185+
Include a snippet similar the following in your Bicep template.
178186

179187
```Bicep
180-
resource aiLoggerWithSystemAssignedIdentity 'Microsoft.ApiManagement/service/loggers@2022-08-01' = {
188+
resource aiLoggerWithUserAssignedIdentity 'Microsoft.ApiManagement/service/loggers@2022-08-01' = {
181189
name: 'ContosoLogger1'
182190
parent: '<APIManagementInstanceName>'
183191
properties: {
184192
loggerType: 'applicationInsights'
185-
description: 'Application Insights logger with system-assigned managed identity'
193+
description: 'Application Insights logger with user-assigned managed identity'
186194
credentials: {
187195
connectionString: 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...'
188-
identityClientId: 'systemAssigned'
196+
identityClientId: '<ClientID>'
189197
}
190198
}
191199
}
@@ -202,52 +210,52 @@ Include a JSON snippet similar to the following in your Azure Resource Manager t
202210
"name": "ContosoLogger1",
203211
"properties": {
204212
"loggerType": "applicationInsights",
205-
"description": "Application Insights logger with system-assigned managed identity",
213+
"description": "Application Insights logger with user-assigned managed identity",
206214
"resourceId": "<ApplicationInsightsResourceID>",
207215
"credentials": {
208216
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
209-
"identityClientId": "SystemAssigned"
217+
"identityClientId": "<ClientID>"
210218
}
211219
}
212220
}
213221
```
214222
---
215-
### Logger with user-assigned managed identity credentials
216223

217-
See the [prerequisites](#prerequisites) for using an API Management managed identity.
224+
### Logger with connection string credentials only
225+
226+
The Application Insights connection string appears in the **Overview** section of your Application Insights resource.
218227

219228
#### [REST API](#tab/rest)
220229

221230
Use the API Management [Logger - Create or Update](/rest/api/apimanagement/current-preview/logger/create-or-update) REST API with the following request body.
222231

232+
If you are configuring the logger for a workspace, use the [Workspace Logger - Create or Update](/rest/api/apimanagement/workspace-logger/create-or-update?view=rest-apimanagement-2023-09-01-preview&preserve-view=true) REST API.
233+
223234
```JSON
224235
{
225236
"properties": {
226237
"loggerType": "applicationInsights",
227-
"description": "adding a new logger with user-assigned managed identity",
238+
"description": "adding a new logger with connection string",
228239
"credentials": {
229-
"connectionString":"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
230-
"identityClientId":"<ClientID>"
240+
"connectionString":"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;..."
231241
}
232242
}
233243
}
234-
235244
```
236245

237246
#### [Bicep](#tab/bicep)
238247

239-
Include a snippet similar the following in your Bicep template.
248+
Include a snippet similar to the following in your Bicep template.
240249

241250
```Bicep
242-
resource aiLoggerWithUserAssignedIdentity 'Microsoft.ApiManagement/service/loggers@2022-08-01' = {
251+
resource aiLoggerWithSystemAssignedIdentity 'Microsoft.ApiManagement/service/loggers@2022-08-01' = {
243252
name: 'ContosoLogger1'
244253
parent: '<APIManagementInstanceName>'
245254
properties: {
246255
loggerType: 'applicationInsights'
247-
description: 'Application Insights logger with user-assigned managed identity'
256+
description: 'Application Insights logger with connection string'
248257
credentials: {
249258
connectionString: 'InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...'
250-
identityClientId: '<ClientID>'
251259
}
252260
}
253261
}
@@ -264,17 +272,17 @@ Include a JSON snippet similar to the following in your Azure Resource Manager t
264272
"name": "ContosoLogger1",
265273
"properties": {
266274
"loggerType": "applicationInsights",
267-
"description": "Application Insights logger with user-assigned managed identity",
275+
"description": "Application Insights logger with connection string",
268276
"resourceId": "<ApplicationInsightsResourceID>",
269277
"credentials": {
270-
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;...",
271-
"identityClientId": "<ClientID>"
272-
}
278+
"connectionString": "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://xxxx.applicationinsights.azure.com/;..."
279+
},
273280
}
274281
}
275282
```
276283
---
277284

285+
278286
## Enable Application Insights logging for your API
279287

280288
Use the following steps to enable Application Insights logging for an API. You can also enable Application Insights logging for all APIs.

0 commit comments

Comments
 (0)