Skip to content

Commit 70e4a18

Browse files
ava-silvercswatt
andauthored
[SVLS-7757] update container app docs to include terraform (#32420)
* [SVLS-7757] update container app docs to include terraform * [SVLS-7757] fix references * edits --------- Co-authored-by: cecilia saixue watt <cecilia.watt@datadoghq.com>
1 parent 3db3c95 commit 70e4a18

File tree

2 files changed

+103
-50
lines changed

2 files changed

+103
-50
lines changed

content/en/serverless/azure_app_service/linux_container.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ Instrumentation is done using a sidecar container. This sidecar container collec
202202
{{< tabs >}}
203203
{{% tab "Datadog CLI" %}}
204204

205-
#### Using the Datadog CLI
206-
207205
#### Locally
208206

209207
Install the [Datadog CLI][601] and [Azure CLI][602], and login to your Azure account using the Azure CLI by running `az login`.
@@ -293,13 +291,11 @@ module "my_web_app" {
293291

294292
Finally, run `terraform apply`, and follow any prompts.
295293

296-
The [Datadog Linux Web App module][4] only deploys the Web App resource, so you need to [deploy your code][5] separately.
294+
The [Datadog Linux Web App module][1] only deploys the Web App resource, so you need to build and push your container separately.
297295

298296
[1]: https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux
299297
[2]: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app
300298
[3]: https://developer.hashicorp.com/terraform/install
301-
[4]: https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux
302-
[5]: https://learn.microsoft.com/en-us/azure/app-service/getting-started
303299

304300
{{% /tab %}}
305301
{{% tab "Manual" %}}

content/en/serverless/azure_container_apps/_index.md

Lines changed: 102 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ further_reading:
1212
text: 'Build secure and scalable Azure serverless applications with the Well-Architected Framework'
1313
---
1414

15-
<div class="alert alert-info">To instrument your Azure Container Apps applications with <code>serverless-init</code>, see <a href="/serverless/guide/aca_serverless_init">Azure Container Apps with serverless-init</a>.</div>
15+
<div class="alert alert-info">To instrument your Azure Container Apps applications with an in-container Datadog Agent, see <a href="/serverless/guide/aca_serverless_init">Azure Container Apps with serverless-init</a>.</div>
1616

1717
## Overview
18-
Azure Container Apps is a fully managed serverless platform for deploying and scaling container-based applications. Datadog provides monitoring and log collection for Container Apps through the [Azure integration][1]. Datadog also provides a solution for instrumenting your Container Apps applications with a purpose-built Agent to enable tracing, custom metrics, and direct log collection.
18+
Azure Container Apps is a fully managed serverless platform for deploying and scaling container-based applications. Datadog provides standard metrics and log collection for Container Apps through the [Azure integration][1]. Datadog also provides a solution for instrumenting your Container Apps applications with a purpose-built Agent to enable tracing, custom metrics, and direct log collection.
1919

2020
{{< img src="serverless/azure_container_apps/aca_top_2.png" alt="Datadog UI, Serverless Monitoring page with Azure Container Apps selected." style="width:100%;" >}}
2121

@@ -25,7 +25,7 @@ Azure Container Apps is a fully managed serverless platform for deploying and sc
2525

2626
Install the [Datadog-Azure integration][4] to collect metrics and logs.
2727

28-
### Application container
28+
### Application
2929

3030
{{< tabs >}}
3131
{{% tab "Node.js" %}}
@@ -36,19 +36,14 @@ Instrument your main application with the `dd-trace-js` library. See [Tracing No
3636
Custom metrics are also collected through the tracer. See the [code examples][2].
3737

3838
#### Logs
39-
The Datadog sidecar uses file tailing to collect logs.
40-
41-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
42-
43-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
39+
As an alternative to collecting logs through the Azure integration, you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
4440

4541
To set up logging in your application, see [Node.js Log Collection][3]. To set up trace log correlation, see [Correlating Node.js Logs and Traces][4].
4642

4743
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#getting-started
4844
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/#code-examples
4945
[3]: /logs/log_collection/nodejs/?tab=winston30
5046
[4]: /tracing/other_telemetry/connect_logs_and_traces/nodejs
51-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
5247
{{% /tab %}}
5348
{{% tab "Python" %}}
5449
#### Tracing
@@ -58,19 +53,14 @@ Instrument your main application with the `dd-trace-py` library. See [Tracing Py
5853
Custom metrics are also collected through the tracer. See the [code examples][2].
5954

6055
#### Logs
61-
The Datadog sidecar uses file tailing to collect logs.
62-
63-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
64-
65-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
56+
As an alternative to collecting logs through the Azure integration, you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
6657

6758
To set up logging in your application, see [Python Log Collection][3]. To set up trace log correlation, see [Correlating Python Logs and Traces][4].
6859

6960
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/python
7061
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=python#code-examples
7162
[3]: /logs/log_collection/python/
7263
[4]: /tracing/other_telemetry/connect_logs_and_traces/python
73-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
7464
{{% /tab %}}
7565
{{% tab "Java" %}}
7666
#### Tracing
@@ -80,19 +70,14 @@ Instrument your main application with the `dd-trace-java` library. See [Tracing
8070
Custom metrics are also collected through the tracer. See the [code examples][2].
8171

8272
#### Logs
83-
The Datadog sidecar uses file tailing to collect logs.
84-
85-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
86-
87-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
73+
As an alternative to collecting logs through the Azure integration, you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
8874

8975
To set up logging in your application, see [Java Log Collection][3]. To set up trace log correlation, see [Correlating Java Logs and Traces][4].
9076

9177
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/java/#getting-started
9278
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=java#code-examples
9379
[3]: /logs/log_collection/java/?tab=winston30
9480
[4]: /tracing/other_telemetry/connect_logs_and_traces/java
95-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
9681
{{% /tab %}}
9782
{{% tab "Go" %}}
9883
#### Tracing
@@ -102,19 +87,14 @@ Instrument your main application with the `dd-trace-go` library. See [Tracing Go
10287
Custom metrics are also collected through the tracer. See the [code examples][2].
10388

10489
#### Logs
105-
The Datadog sidecar uses file tailing to collect logs.
106-
107-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
108-
109-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
90+
As an alternative to collecting logs through the Azure integration, you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
11091

11192
To set up logging in your application, see [Go Log Collection][3]. To set up trace log correlation, see [Correlating Go Logs and Traces][4].
11293

11394
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/go
11495
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=go#code-examples
11596
[3]: /logs/log_collection/go/
11697
[4]: /tracing/other_telemetry/connect_logs_and_traces/go
117-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
11898
{{% /tab %}}
11999
{{% tab ".NET" %}}
120100
#### Tracing
@@ -124,19 +104,14 @@ Instrument your main application with the `dd-trace-dotnet` library. See [Tracin
124104
Custom metrics are also collected through the tracer. See the [code examples][2].
125105

126106
#### Logs
127-
The Datadog sidecar uses file tailing to collect logs.
128-
129-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
130-
131-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
107+
Instead of collecting logs through the Azure integration, alternatively you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
132108

133109
To set up logging in your application, see [.NET Log Collection][3]. To set up trace log correlation, see [Correlating .NET Logs and Traces][4].
134110

135111
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/dotnet-core/?tab=linux
136112
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=dotnet#code-examples
137113
[3]: /logs/log_collection/csharp/
138114
[4]: /tracing/other_telemetry/connect_logs_and_traces/dotnet
139-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
140115
{{% /tab %}}
141116
{{% tab "PHP" %}}
142117
#### Tracing
@@ -146,30 +121,102 @@ Instrument your main application with the `dd-trace-php` library. See [Tracing P
146121
Custom metrics are also collected through the tracer. See the [code examples][2].
147122

148123
#### Logs
149-
The Datadog sidecar uses file tailing to collect logs.
150-
151-
In Azure, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][5]. Use type "Ephemeral storage" when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
152-
153-
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
124+
As an alternative to collecting logs through the Azure integration, you can use the Datadog sidecar with file tailing to collect application logs. Ensure that the logging path used in your application matches the path set in `DD_SERVERLESS_LOG_PATH` when setting up your sidecar in the [Instrumentation](#instrumentation) section.
154125

155126
To set up logging in your application, see [PHP Log Collection][3]. To set up trace log correlation, see [Correlating PHP Logs and Traces][4].
156127

157128
[1]: /tracing/trace_collection/automatic_instrumentation/dd_libraries/php/#getting-started
158129
[2]: /metrics/custom_metrics/dogstatsd_metrics_submission/?code-lang=php#code-examples
159130
[3]: /logs/log_collection/php/
160131
[4]: /tracing/other_telemetry/connect_logs_and_traces/php
161-
[5]: https://learn.microsoft.com/en-us/azure/container-apps/storage-mounts?pivots=azure-cli&tabs=smb#replica-scoped-storage
162132
{{% /tab %}}
163133
{{< /tabs >}}
164134

165-
#### Environment variables
166-
Because Azure Container Apps is built on Kubernetes, you cannot share environment variables between containers. You must set Datadog environment variables on both your application and sidecar containers.
135+
### Instrumentation
136+
137+
{{< tabs >}}
138+
{{% tab "Terraform" %}}
139+
140+
The [Datadog Terraform module for Container Apps][1] wraps the [`azurerm_container_app`][2] resource and automatically configures your Container App for Datadog Serverless Monitoring by adding required environment variables and the serverless-init sidecar.
141+
142+
If you don't already have Terraform set up, [install Terraform][3], create a new directory, and make a file called `main.tf`.
143+
144+
Then, add the following to your Terraform configuration, updating it as necessary based on your needs:
145+
146+
```tf
147+
variable "datadog_api_key" {
148+
description = "Your Datadog API key"
149+
type = string
150+
sensitive = true
151+
}
152+
153+
provider "azurerm" {
154+
features {}
155+
subscription_id = "00000000-0000-0000-0000-000000000000" // Replace with your subscription ID
156+
}
157+
158+
resource "azurerm_container_app_environment" "my_env" {
159+
name = "my-container-app-env" // Replace with your container app environment name
160+
resource_group_name = "my-resource-group" // Replace with your resource group name
161+
location = "eastus"
162+
}
163+
164+
module "my_container_app" {
165+
source = "DataDog/container-app-datadog/azurerm"
166+
version = "~> 1.0"
167+
168+
name = "my-container-app" // Replace with your container app name
169+
resource_group_name = "my-resource-group" // Replace with your resource group name
170+
container_app_environment_id = azurerm_container_app_environment.my_env.id
171+
172+
datadog_api_key = var.datadog_api_key
173+
datadog_site = "datadoghq.com" // Replace with your Datadog site
174+
datadog_service = "my-service" // Replace with your service name
175+
datadog_env = "dev" // Replace with your environment (e.g. prod, staging, dev)
176+
datadog_version = "0.1.0" // Replace with your application version
177+
178+
revision_mode = "Single"
179+
workload_profile_name = "Consumption"
180+
ingress = {
181+
external_enabled = true
182+
target_port = 8080
183+
traffic_weight = [{
184+
percentage = 100
185+
latest_revision = true
186+
}]
187+
}
188+
template = {
189+
container = [{
190+
cpu = 0.5
191+
memory = "1Gi"
192+
image = "docker.io/your-docker-image:latest" // Replace with your Docker image
193+
name = "main"
194+
}]
195+
}
196+
}
197+
```
198+
199+
Finally, run `terraform apply`, and follow any prompts.
200+
201+
The [Datadog Container App module][1] only deploys the Container App resource, so you need to build and push your container separately.
202+
203+
[1]: https://registry.terraform.io/modules/DataDog/container-app-datadog/azurerm/latest
204+
[2]: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app
205+
[3]: https://developer.hashicorp.com/terraform/install
206+
207+
208+
{{% /tab %}}
209+
{{% tab "Manual" %}}
210+
211+
212+
### Application environment variables
213+
Because Azure Container Apps is built on Kubernetes, you cannot share environment variables between containers.
167214

168215
| Name | Description |
169216
| ---- | ----------- |
170217
| `DD_SERVICE` | How you want to tag your service. For example, `sidecar-azure`. |
171218
| `DD_ENV` | How you want to tag your env. For example, `prod`.|
172-
| `DD_VERSION` | How you want to tag your version. |
219+
| `DD_VERSION` | How you want to tag your application version. |
173220

174221
### Sidecar container
175222
1. In the Azure Portal, navigate to **Application** > **Revisions and replicas**. Select **Create new revision**.
@@ -184,7 +231,7 @@ Because Azure Container Apps is built on Kubernetes, you cannot share environmen
184231
4. Add a volume mount using [replica-scoped storage][2]. Use type "Ephemeral storage" when creating your volume. Ensure that the name and mount path matches the mount you configured in the application container.
185232
5. Set the environment variables in the following table:
186233

187-
#### Environment variables
234+
#### Sidecar Environment variables
188235
| Name | Description |
189236
| ---- | ----------- |
190237
| `DD_AZURE_SUBSCRIPTION_ID` | **Required**. Your Azure subscription ID. |
@@ -193,8 +240,18 @@ Because Azure Container Apps is built on Kubernetes, you cannot share environmen
193240
| `DD_SITE` | Your Datadog site: `{{< region-param key="dd_site" code="true" >}}`
194241
| `DD_SERVICE` | How you want to tag your service. For example, `sidecar-azure`. |
195242
| `DD_ENV` | How you want to tag your env. For example, `prod`.|
196-
| `DD_VERSION` | How you want to tag your version. |
197-
| `DD_SERVERLESS_LOG_PATH` | Where you write your logs. For example, `/LogFiles/*.log`. |
243+
| `DD_VERSION` | How you want to tag your application version. |
244+
| `DD_SERVERLESS_LOG_PATH` | If using the agent for log collection, where you write your logs. For example, `/LogFiles/*.log`. This must match the logging path set up in [Application](#application) |
245+
246+
### Logging
247+
248+
If using the Datadog Agent for log collection, add a volume mount to the sidecar container *and* your application containers using [replica-scoped storage][2]. Use type **Ephemeral storage** when creating your volume. The examples on this page use the volume name `logs` and the mount path `/LogFiles`.
249+
250+
{{< img src="serverless/azure_container_apps/aca-volume-mount.png" alt="Adding a volume mount to a container in Azure" style="width:60%;" >}}
251+
252+
{{% /tab %}}
253+
{{< /tabs >}}
254+
198255

199256
### Example application
200257

0 commit comments

Comments
 (0)