{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "string"
},
"slotName": {
"type": "string"
},
// ...
"datadogApiKey": {
"type": "securestring"
},
"existingStickyAppSettingNames": {
"type": "array",
"defaultValue": [],
"metadata": { "description": "Names of app settings already marked slot-sticky on this web app. Pass [] for a new app with no existing sticky settings. This template does a full replace of slotConfigNames — omitting an existing sticky setting name will de-sticky it." }
}
},
"variables": {
"datadogAppSettings": [
{ "name": "DD_API_KEY", "value": "[parameters('datadogApiKey')]" },
{ "name": "DD_SITE", "value": "datadoghq.com" }, // Replace with your Datadog site
{ "name": "DD_SERVICE", "value": "my-service" }, // Replace with your service name
{ "name": "DD_ENV", "value": "staging" }, // Set a distinct value for each slot
{ "name": "DD_VERSION", "value": "0.0.0" }, // Replace with your application version
{ "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE", "value": "true" },
// Uncomment for .NET applications
// { "name": "DD_DOTNET_TRACER_HOME", "value": "/datadog/tracer" }
// { "name": "CORECLR_ENABLE_PROFILING", "value": "1" }
// { "name": "CORECLR_PROFILER", "value": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}" }
// { "name": "CORECLR_PROFILER_PATH", "value": "/datadog/tracer/Datadog.Trace.ClrProfiler.Native.so" }
{ "name": "DD_LOGS_INJECTION", "value": "true" },
{ "name": "DD_TRACE_ENABLED", "value": "true" }
// Add any additional options here
],
"yourAppSettings": [
// Add your app settings here
]
},
"resources": {
"slot": {
"type": "Microsoft.Web/sites/slots",
"apiVersion": "2025-03-01",
"name": "[concat(parameters('webAppName'), '/', parameters('slotName'))]",
"kind": "app,linux,container",
// ...
"properties": {
// ...
"siteConfig": {
// ...
"linuxFxVersion": "SITECONTAINERS",
"appSettings": "[concat(variables('datadogAppSettings'), variables('yourAppSettings'))]"
}
}
},
"mainContainer": {
"type": "Microsoft.Web/sites/slots/sitecontainers",
"apiVersion": "2025-03-01",
"name": "[concat(parameters('webAppName'), '/', parameters('slotName'), '/main')]",
"properties": {
"isMain": true,
"image": "index.docker.io/your/image:tag", // Replace with your Application Image
"targetPort": "8080" // Replace with your Application's Port
}
},
"sidecar": {
"type": "Microsoft.Web/sites/slots/sitecontainers",
"apiVersion": "2025-03-01",
"name": "[concat(parameters('webAppName'), '/', parameters('slotName'), '/datadog-sidecar')]",
"properties": {
"image": "index.docker.io/datadog/serverless-init:latest",
"isMain": false,
"targetPort": "8126",
"copy": [{
"name": "environmentVariables", "count": "[length(variables('datadogAppSettings'))]",
"input": {
"name": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]",
"value": "[variables('datadogAppSettings')[copyIndex('environmentVariables')].name]"
}
}]
}
},
// Marks DD_ENV as slot-sticky so your `env` tag persists across slot swaps. Replaces the
// full slotConfigNames list — existingStickyAppSettingNames must include any settings
// already marked sticky or they will be de-stickied.
"stickySettings": {
"type": "Microsoft.Web/sites/config",
"apiVersion": "2025-03-01",
"name": "[concat(parameters('webAppName'), '/slotConfigNames')]",
"properties": {
"appSettingNames": "[union(parameters('existingStickyAppSettingNames'), createArray('DD_ENV'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites/slots', parameters('webAppName'), parameters('slotName'))]"
]
}
}
}