Skip to content

Commit 9541d3a

Browse files
Merge pull request #293801 from craigshoemaker/aca/jason/otel-bicep
[Container Apps] Update: Add Bicep to OTel doc
2 parents 776362f + a98611f commit 9541d3a

File tree

1 file changed

+184
-10
lines changed

1 file changed

+184
-10
lines changed

articles/container-apps/opentelemetry-agents.md

Lines changed: 184 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn to record and query data collected using OpenTelemetry in Azu
44
services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
7-
ms.date: 12/02/2024
7+
ms.date: 01/29/2025
88
ms.author: cshoe
99
ms.topic: how-to
1010
---
@@ -61,7 +61,7 @@ If you want to protect your Application Insights resource from misuse, see [Micr
6161

6262
# [ARM template](#tab/arm)
6363

64-
Before you deploy this template, replace placeholders surrounded by `<>` with your values.
64+
Before you deploy this template, replace the `<PLACEHOLDERS>` with your values.
6565

6666
```json
6767
{
@@ -83,9 +83,35 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
8383
}
8484
```
8585

86+
# [Bicep](#tab/bicep)
87+
88+
```bicep
89+
resource environment 'Microsoft.App/managedEnvironments@2024-10-02-preview' = {
90+
...
91+
properties: {
92+
appInsightsConfiguration: {
93+
connectionString: '<APP_INSIGHTS_CONNECTION_STRING>'
94+
}
95+
openTelemetryConfiguration: {
96+
...
97+
tracesConfiguration: {
98+
destinations: [
99+
'appInsights'
100+
]
101+
}
102+
logsConfiguration: {
103+
destinations: [
104+
'appInsights'
105+
]
106+
}
107+
}
108+
}
109+
}
110+
```
111+
86112
# [Azure CLI](#tab/azure-cli)
87113

88-
Before you run this command, replace placeholders surrounded by `<>` with your values.
114+
Before you run this command, replace the `<PLACEHOLDERS>` with your values.
89115

90116
```azurecli
91117
az containerapp env telemetry app-insights set \
@@ -142,7 +168,7 @@ The Datadog agent configuration requires a value for `site` and `key` from your
142168
| `DD_SITE` | `site` |
143169
| `DD_API_KEY` | `key` |
144170

145-
Once you have these configuration details, you can configure the agent via your container app's ARM template or with Azure CLI commands.
171+
Once you have these configuration details, you can configure the agent via your container app's ARM or Bicep template or with Azure CLI commands.
146172

147173
Avoid specifying the value of a secret, such as your Datadog API key, directly in a production environment. Instead, use a reference to a secret stored in Azure Key Vault.
148174

@@ -160,7 +186,7 @@ For more information, see:
160186

161187
Create a [parameter file](/azure/azure-resource-manager/templates/parameter-files) to retrieve your Datadog API key from an Azure Key Vault.
162188

163-
Before you deploy the following files, replace placeholders surrounded by `<>` with your values.
189+
Before you deploy the following files, replace the `<PLACEHOLDERS>` with your values.
164190

165191
```json
166192
{
@@ -179,7 +205,7 @@ Before you deploy the following files, replace placeholders surrounded by `<>` w
179205
}
180206
```
181207

182-
You can now reference the `datadogapikey` parameter in your ARM Template.
208+
You can now reference the `datadogapikey` parameter in your ARM template.
183209

184210
```json
185211
{
@@ -211,7 +237,7 @@ You can now reference the `datadogapikey` parameter in your ARM Template.
211237
}
212238
```
213239

214-
To deploy the resource, run the following Azure CLI command, replacing the placeholders surrounded by `<>` with your values.
240+
To deploy the resource, run the following Azure CLI command, replacing the `<PLACEHOLDERS>` with your values.
215241

216242
```azurecli
217243
az deployment group create \
@@ -220,9 +246,60 @@ az deployment group create \
220246
--parameters <PARAMETER_FILE>
221247
```
222248

249+
# [Bicep](#tab/bicep)
250+
251+
Create a [parameter file](/azure/azure-resource-manager/bicep/parameter-files) to retrieve your Datadog API key from an Azure Key Vault.
252+
253+
Before you deploy the following files, replace the `<PLACEHOLDERS>` with your values.
254+
255+
```bicep
256+
using '<BICEP_TEMPLATE_FILE>'
257+
258+
param datadogapikey = az.getSecret('<SUBSCRIPTION_ID>', '<RESOURCE_GROUP_NAME>', '<KEY_VAULT_NAME>', '<SECRET_NAME>', '<SECRET_VERSION_ID>')
259+
```
260+
261+
The subscription ID has the form `123e4567-e89b-12d3-a456-426614174000`. The secret version ID has the form `123e4567e89b12d3a456426614174000`.
262+
263+
You can now reference the `datadogapikey` parameter in your Bicep template.
264+
265+
```bicep
266+
@secure()
267+
param datadogapikey string
268+
269+
resource environment 'Microsoft.App/managedEnvironments@2024-10-02-preview' = {
270+
...
271+
properties: {
272+
openTelemetryConfiguration: {
273+
destinationsConfiguration: {
274+
dataDogConfiguration: {
275+
site: 'datadoghq.com'
276+
key: datadogapikey
277+
}
278+
}
279+
...
280+
metricsConfiguration: {
281+
destinations: [
282+
'dataDog'
283+
'customDashboard'
284+
]
285+
}
286+
}
287+
}
288+
}
289+
```
290+
291+
To deploy the resource, run the following Azure CLI command, replacing the `<PLACEHOLDERS>` with your values.
292+
293+
```azurecli
294+
az deployment group create \
295+
--resource-group <RESOURCE_GROUP> \
296+
--template-file <BICEP_TEMPLATE_FILE> \
297+
--parameters <PARAMETER_FILE>
298+
```
299+
223300
# [Azure CLI](#tab/azure-cli)
224301

225-
Before you run this command, replace placeholders surrounded by `<>` with your values.
302+
Before you run this command, replace the `<PLACEHOLDERS>` with your values.
226303

227304
```azurecli
228305
az containerapp env telemetry data-dog set \
@@ -315,6 +392,49 @@ While you can set up as many OTLP-configured endpoints as you like, each endpoin
315392

316393
```
317394

395+
# [Bicep](#tab/bicep)
396+
397+
```bicep
398+
resource environment 'Microsoft.App/managedEnvironments@2024-10-02-preview' = {
399+
...
400+
properties: {
401+
openTelemetryConfiguration: {
402+
destinationsConfiguration: {
403+
otlpConfigurations: [
404+
{
405+
name: 'otlp1'
406+
endpoint: 'ENDPOINT_URL_1'
407+
insecure: false
408+
headers: 'api-key-1=key'
409+
}
410+
{
411+
name: 'otlp2'
412+
endpoint: 'ENDPOINT_URL_2'
413+
insecure: true
414+
},
415+
]
416+
}
417+
logsConfiguration: {
418+
destinations: [
419+
'otlp2'
420+
]
421+
}
422+
tracesConfiguration: {
423+
destinations: [
424+
'otlp1'
425+
'otlp2'
426+
]
427+
}
428+
metricsConfiguration: {
429+
destinations: [
430+
'otlp1'
431+
]
432+
}
433+
}
434+
}
435+
}
436+
```
437+
318438
# [Azure CLI](#tab/azure-cli)
319439

320440
```azurecli
@@ -454,11 +574,13 @@ The following example ARM template shows how to use an OTLP endpoint named `cust
454574

455575
## Example OpenTelemetry configuration
456576

457-
The following example ARM template shows how you might configure your container app to collect telemetry data using Azure Monitor Application Insights, Datadog, and with a custom OTLP agent named `customDashboard`.
577+
The following example template shows how you might configure your container app to collect telemetry data using Azure Monitor Application Insights, Datadog, and with a custom OTLP agent named `customDashboard`.
458578

459579
This example works with the parameter file used to retrieve the [Datadog API](#datadog) key from an Azure Key Vault.
460580

461-
Before you deploy this template, replace placeholders surrounded by `<>` with your values.
581+
Before you deploy this template, replace the `<PLACEHOLDERS>` with your values.
582+
583+
# [ARM template](#tab/arm-example)
462584

463585
```json
464586
{
@@ -504,6 +626,58 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
504626
}
505627
```
506628

629+
# [Bicep](#tab/bicep-example)
630+
631+
```bicep
632+
@secure()
633+
param datadogapikey string
634+
635+
resource environment 'Microsoft.App/managedEnvironments@2024-10-02-preview' = {
636+
name: '<ENVIRONMENT_NAME>'
637+
location: '<LOCATION>'
638+
properties: {
639+
appInsightsConfiguration: {
640+
connectionString: '<APP_INSIGHTS_CONNECTION_STRING>'
641+
}
642+
openTelemetryConfiguration: {
643+
destinationsConfiguration: {
644+
dataDogConfiguration: {
645+
site: 'datadoghq.com'
646+
key: datadogapikey
647+
}
648+
otlpConfigurations: [
649+
{
650+
name: 'customDashboard'
651+
endpoint: '<OTLP_ENDPOINT_URL>'
652+
insecure: true
653+
}
654+
]
655+
}
656+
tracesConfiguration: {
657+
destinations: [
658+
'appInsights'
659+
'customDashboard'
660+
]
661+
}
662+
logsConfiguration: {
663+
destinations: [
664+
'appInsights'
665+
'customDashboard'
666+
]
667+
}
668+
metricsConfiguration: {
669+
destinations: [
670+
'dataDog'
671+
'customDashboard'
672+
]
673+
}
674+
}
675+
}
676+
}
677+
```
678+
679+
---
680+
507681
For more information, see [Microsoft.App/managedEnvironments](/azure/templates/microsoft.app/2024-02-02-preview/managedenvironments).
508682

509683
## Environment variables

0 commit comments

Comments
 (0)