Skip to content

Commit f9e5306

Browse files
committed
[ACA] [345347] Add Bicep template to OTel doc
1 parent 879addd commit f9e5306

File tree

1 file changed

+183
-10
lines changed

1 file changed

+183
-10
lines changed

articles/container-apps/opentelemetry-agents.md

Lines changed: 183 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,59 @@ 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 './main.bicep'
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+
```json
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+
metricsConfiguration: {
280+
destinations: [
281+
'dataDog'
282+
'customDashboard'
283+
]
284+
}
285+
}
286+
...
287+
}
288+
```
289+
290+
To deploy the resource, run the following Azure CLI command, replacing the `<PLACEHOLDERS>` with your values.
291+
292+
```azurecli
293+
az deployment group create \
294+
--resource-group <RESOURCE_GROUP> \
295+
--template-file <BICEP_TEMPLATE_FILE> \
296+
--parameters <PARAMETER_FILE>
297+
```
298+
223299
# [Azure CLI](#tab/azure-cli)
224300

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

227303
```azurecli
228304
az containerapp env telemetry data-dog set \
@@ -315,6 +391,49 @@ While you can set up as many OTLP-configured endpoints as you like, each endpoin
315391

316392
```
317393

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

320439
```azurecli
@@ -454,11 +573,13 @@ The following example ARM template shows how to use an OTLP endpoint named `cust
454573

455574
## Example OpenTelemetry configuration
456575

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`.
576+
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`.
458577

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

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

463584
```json
464585
{
@@ -504,6 +625,58 @@ Before you deploy this template, replace placeholders surrounded by `<>` with yo
504625
}
505626
```
506627

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

509682
## Environment variables

0 commit comments

Comments
 (0)