Skip to content

Commit c222bd9

Browse files
authored
[SVLS-9256] improve deployment slots docs (#37336)
1 parent 24e6c29 commit c222bd9

3 files changed

Lines changed: 177 additions & 9 deletions

File tree

content/en/serverless/azure_app_service/linux_code.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Set your Datadog site to {{< region-param key="dd_site" code="true" >}}. Default
133133

134134
Additional flags, like `--service` and `--env`, can be used to set the service and environment tags. For a full list of options, run `datadog-ci aas instrument --help`.
135135

136+
`datadog-ci aas instrument` only needs to be run once to set up instrumentation. You do not need to re-run it on every code deployment, only re-run it to change your Datadog configuration.
137+
136138
#### Azure Cloud Shell
137139

138140
To use the Datadog CLI in [Azure Cloud Shell][203], open a cloud shell, set your API key and site in the `DD_API_KEY` and `DD_SITE` environment variables, and use `npx` to run the CLI directly:
@@ -469,18 +471,28 @@ To instrument a [deployment slot][801] instead of the main web app, use one of t
469471
{{< tabs >}}
470472
{{% tab "Datadog CLI" %}}
471473

472-
Using the [Datadog CLI][1] (v5.9.0+), add the `--slot` flag. Use `--env` to set a distinct environment tag for the slot:
474+
Using the [Datadog CLI][1] (v5.9.0+), add the `--slot` flag. Use `--service`, `--env`, and `--version` to set distinct unified service tagging values for the slot.
473475

476+
To find the names of your deployment slots, run:
474477
```shell
475-
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name> --slot <slot-name> --env <slot-env>
478+
az webapp deployment slot list --query '[].name' -o tsv -g <resource-group> -n <web-app>
479+
```
480+
481+
```shell
482+
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name> \
483+
--slot <slot-name> \
484+
--service <service-name> --env <slot-env> --version <app-version>
476485
```
477486

478487
Alternatively, provide the full slot resource ID with the `--resource-id` flag:
479488

480489
```shell
481-
datadog-ci aas instrument --resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/slots/<slot-name> --env <slot-env>
490+
datadog-ci aas instrument --resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/slots/<slot-name> \
491+
--service <service-name> --env <slot-env> --version <app-version>
482492
```
483493

494+
**Note**: When you pass `--env`, the CLI automatically marks `DD_ENV` as a sticky setting, so your `env` tag persists across slot swaps.
495+
484496
[1]: https://github.com/DataDog/datadog-ci#how-to-install-the-cli
485497

486498
{{% /tab %}}
@@ -515,6 +527,8 @@ module "my_web_app_slot" {
515527

516528
Run `terraform apply`, and follow any prompts.
517529

530+
**Note**: When `datadog_env` is set on your main web app module, the module marks `DD_ENV` as a sticky setting, so your `env` tag persists across slot swaps.
531+
518532
[1]: https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux-slot
519533

520534
{{% /tab %}}
@@ -526,6 +540,9 @@ Update your template to target a deployment slot instead of the main web app:
526540
param webAppName string
527541
param slotName string
528542
543+
@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.')
544+
param existingStickyAppSettingNames array = []
545+
529546
resource webApp 'Microsoft.Web/sites@2025-03-01' existing = {
530547
name: webAppName
531548
}
@@ -545,6 +562,18 @@ resource slot 'Microsoft.Web/sites/slots@2025-03-01' = {
545562
}
546563
}
547564
565+
// Marks DD_ENV as slot-sticky so your `env` tag persists across slot swaps. Replaces the
566+
// full slotConfigNames list — existingStickyAppSettingNames must include any settings already
567+
// marked sticky or they will be de-stickied.
568+
resource stickySettings 'Microsoft.Web/sites/config@2025-03-01' = {
569+
parent: webApp
570+
name: 'slotConfigNames'
571+
properties: {
572+
appSettingNames: union(existingStickyAppSettingNames, ['DD_ENV'])
573+
}
574+
dependsOn: [slot]
575+
}
576+
548577
@secure()
549578
param datadogApiKey string
550579
@@ -583,6 +612,10 @@ Redeploy your updated template:
583612
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
584613
```
585614

615+
**Note**: Azure app settings swap between slots by default. The `slotConfigNames` resource above marks `DD_ENV` as sticky, so your `env` tag persists across slot swaps.
616+
617+
The `slotConfigNames` resource does a full replace of the sticky-settings list. Pass any settings already marked sticky in `existingStickyAppSettingNames`, or `[]` for a new app. Any name omitted is de-stickied.
618+
586619
{{% /tab %}}
587620
{{% tab "ARM Template" %}}
588621

@@ -602,6 +635,11 @@ Update your template to target a deployment slot instead of the main web app:
602635
// ...
603636
"datadogApiKey": {
604637
"type": "securestring"
638+
},
639+
"existingStickyAppSettingNames": {
640+
"type": "array",
641+
"defaultValue": [],
642+
"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." }
605643
}
606644
},
607645
"variables": {
@@ -655,6 +693,20 @@ Update your template to target a deployment slot instead of the main web app:
655693
}
656694
}]
657695
}
696+
},
697+
// Marks DD_ENV as slot-sticky so your `env` tag persists across slot swaps. Replaces the
698+
// full slotConfigNames list — existingStickyAppSettingNames must include any settings
699+
// already marked sticky or they will be de-stickied.
700+
"stickySettings": {
701+
"type": "Microsoft.Web/sites/config",
702+
"apiVersion": "2025-03-01",
703+
"name": "[concat(parameters('webAppName'), '/slotConfigNames')]",
704+
"properties": {
705+
"appSettingNames": "[union(parameters('existingStickyAppSettingNames'), createArray('DD_ENV'))]"
706+
},
707+
"dependsOn": [
708+
"[resourceId('Microsoft.Web/sites/slots', parameters('webAppName'), parameters('slotName'))]"
709+
]
658710
}
659711
}
660712
}
@@ -666,6 +718,10 @@ Redeploy your updated template:
666718
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
667719
```
668720

721+
**Note**: Azure app settings swap between slots by default. The `slotConfigNames` resource above marks `DD_ENV` as sticky, so your `env` tag persists across slot swaps.
722+
723+
The `slotConfigNames` resource does a full replace of the sticky-settings list. Pass any settings already marked sticky in `existingStickyAppSettingNames`, or `[]` for a new app. Any name omitted is de-stickied.
724+
669725
{{% /tab %}}
670726
{{< /tabs >}}
671727

content/en/serverless/azure_app_service/linux_container.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ Set your Datadog site to {{< region-param key="dd_site" code="true" >}}. Default
226226

227227
Additional flags, like `--service` and `--env`, can be used to set the service and environment tags. For a full list of options, run `datadog-ci aas instrument --help`.
228228

229+
`datadog-ci aas instrument` only needs to be run once to set up instrumentation. You do not need to re-run it on every code deployment, only re-run it to change your Datadog configuration.
230+
229231
#### Azure Cloud Shell
230232

231233
To use the Datadog CLI in [Azure Cloud Shell][603], open cloud shell and use `npx` to run the CLI directly. Set your API key and site in the `DD_API_KEY` and `DD_SITE` environment variables, and then run the CLI:
@@ -534,18 +536,28 @@ To instrument a [deployment slot][901] instead of the main web app, use one of t
534536
{{< tabs >}}
535537
{{% tab "Datadog CLI" %}}
536538

537-
Using the [Datadog CLI][1] (v5.9.0+), add the `--slot` flag. Use `--env` to set a distinct environment tag for the slot:
539+
Using the [Datadog CLI][1] (v5.9.0+), add the `--slot` flag. Use `--service`, `--env`, and `--version` to set distinct unified service tagging values for the slot.
538540

541+
To find the names of your deployment slots, run:
539542
```shell
540-
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name> --slot <slot-name> --env <slot-env>
543+
az webapp deployment slot list --query '[].name' -o tsv -g <resource-group> -n <web-app>
544+
```
545+
546+
```shell
547+
datadog-ci aas instrument -s <subscription-id> -g <resource-group-name> -n <app-service-name> \
548+
--slot <slot-name> \
549+
--service <service-name> --env <slot-env> --version <app-version>
541550
```
542551

543552
Alternatively, provide the full slot resource ID with the `--resource-id` flag:
544553

545554
```shell
546-
datadog-ci aas instrument --resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/slots/<slot-name> --env <slot-env>
555+
datadog-ci aas instrument --resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/slots/<slot-name> \
556+
--service <service-name> --env <slot-env> --version <app-version>
547557
```
548558

559+
**Note**: When you pass `--env`, the CLI automatically marks `DD_ENV` as a sticky setting, so your `env` tag persists across slot swaps.
560+
549561
[1]: https://github.com/DataDog/datadog-ci#how-to-install-the-cli
550562

551563
{{% /tab %}}
@@ -581,6 +593,8 @@ module "my_web_app_slot" {
581593

582594
Run `terraform apply`, and follow any prompts.
583595

596+
**Note**: When `datadog_env` is set on your main web app module, the module marks `DD_ENV` as a sticky setting, so your `env` tag persists across slot swaps.
597+
584598
[1]: https://registry.terraform.io/modules/DataDog/web-app-datadog/azurerm/latest/submodules/linux-slot
585599

586600
{{% /tab %}}
@@ -592,6 +606,9 @@ Update your template to target a deployment slot instead of the main web app:
592606
param webAppName string
593607
param slotName string
594608
609+
@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.')
610+
param existingStickyAppSettingNames array = []
611+
595612
resource webApp 'Microsoft.Web/sites@2025-03-01' existing = {
596613
name: webAppName
597614
}
@@ -613,6 +630,18 @@ resource slot 'Microsoft.Web/sites/slots@2025-03-01' = {
613630
}
614631
}
615632
633+
// Marks DD_ENV as slot-sticky so your `env` tag persists across slot swaps. Replaces the
634+
// full slotConfigNames list — existingStickyAppSettingNames must include any settings already
635+
// marked sticky or they will be de-stickied.
636+
resource stickySettings 'Microsoft.Web/sites/config@2025-03-01' = {
637+
parent: webApp
638+
name: 'slotConfigNames'
639+
properties: {
640+
appSettingNames: union(existingStickyAppSettingNames, ['DD_ENV'])
641+
}
642+
dependsOn: [slot]
643+
}
644+
616645
resource mainContainer 'Microsoft.Web/sites/slots/sitecontainers@2025-03-01' = {
617646
parent: slot
618647
name: 'main'
@@ -661,6 +690,10 @@ Redeploy your updated template:
661690
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
662691
```
663692

693+
**Note**: Azure app settings swap between slots by default. The `slotConfigNames` resource above marks `DD_ENV` as sticky, so your `env` tag persists across slot swaps.
694+
695+
The `slotConfigNames` resource does a full replace of the sticky-settings list. Pass any settings already marked sticky in `existingStickyAppSettingNames`, or `[]` for a new app. Any name omitted is de-stickied.
696+
664697
{{% /tab %}}
665698
{{% tab "ARM Template" %}}
666699

@@ -680,6 +713,11 @@ Update your template to target a deployment slot instead of the main web app:
680713
// ...
681714
"datadogApiKey": {
682715
"type": "securestring"
716+
},
717+
"existingStickyAppSettingNames": {
718+
"type": "array",
719+
"defaultValue": [],
720+
"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." }
683721
}
684722
},
685723
"variables": {
@@ -745,6 +783,20 @@ Update your template to target a deployment slot instead of the main web app:
745783
}
746784
}]
747785
}
786+
},
787+
// Marks DD_ENV as slot-sticky so your `env` tag persists across slot swaps. Replaces the
788+
// full slotConfigNames list — existingStickyAppSettingNames must include any settings
789+
// already marked sticky or they will be de-stickied.
790+
"stickySettings": {
791+
"type": "Microsoft.Web/sites/config",
792+
"apiVersion": "2025-03-01",
793+
"name": "[concat(parameters('webAppName'), '/slotConfigNames')]",
794+
"properties": {
795+
"appSettingNames": "[union(parameters('existingStickyAppSettingNames'), createArray('DD_ENV'))]"
796+
},
797+
"dependsOn": [
798+
"[resourceId('Microsoft.Web/sites/slots', parameters('webAppName'), parameters('slotName'))]"
799+
]
748800
}
749801
}
750802
}
@@ -756,6 +808,10 @@ Redeploy your updated template:
756808
az deployment group create --resource-group <RESOURCE GROUP> --template-file <TEMPLATE FILE>
757809
```
758810

811+
**Note**: Azure app settings swap between slots by default. The `slotConfigNames` resource above marks `DD_ENV` as sticky, so your `env` tag persists across slot swaps.
812+
813+
The `slotConfigNames` resource does a full replace of the sticky-settings list. Pass any settings already marked sticky in `existingStickyAppSettingNames`, or `[]` for a new app. Any name omitted is de-stickied.
814+
759815
{{% /tab %}}
760816
{{< /tabs >}}
761817

0 commit comments

Comments
 (0)