Skip to content

[SVLS-9100] fix(install): Function App slot workaround + install templates (#455)#457

Merged
Lewis-E merged 8 commits into
masterfrom
worktree-issue-455-functionapp-install
Jun 1, 2026
Merged

[SVLS-9100] fix(install): Function App slot workaround + install templates (#455)#457
Lewis-E merged 8 commits into
masterfrom
worktree-issue-455-functionapp-install

Conversation

@Lewis-E

@Lewis-E Lewis-E commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses #455 — intermittent MoveDirectory failures when installing the Datadog extension on Azure Function App deployment slots.

Root cause: The Functions runtime holds file locks on C:\home\SiteExtensions\ after code deployment. If a site extension ARM deployment runs while those handles are open, Kudu's MoveDirectory step fails. This does not affect Web Apps.

Fix: Set WEBSITE_PRIVATE_EXTENSIONS=0 as a sticky slot setting. This prevents the Functions runtime from loading private site extensions on that slot (releasing the file locks). Because the setting is sticky, it stays on the staging slot after swaps and never affects production.

Changes

install-templates/ (renamed from ARM/)

  • install-web-app.{json,bicep} — Web App install templates
  • install-web-app-slot.{json,bicep} — Web App deployment slot templates
  • install-function-app-slot.{json,bicep}New: Function App slot templates with WEBSITE_PRIVATE_EXTENSIONS=0 sticky setting + slotConfigNames resource, dependsOn ordering to ensure setting is applied before extension install
  • All templates versioned (metadata.version in JSON, // Version: in Bicep) to allow comparison against docs inline snippets

PowerShell scripts

  • install-latest-extension.ps1 v2.0.0: adds -SlotName parameter; when provided against a Function App, automatically applies WEBSITE_PRIVATE_EXTENSIONS=0 as a sticky slot setting.
  • update-all-site-extensions.ps1 v2.0.0: adds -IncludeSlots flag to enumerate and update deployment slots across a resource group

README.md

  • Adds "In-repo resources" section pointing at install-templates/ and management-scripts/extension/

Companion PR

Must be merged alongside: DataDog/documentation#36956

The docs PR updates the ARM/install-templates/ link and adds the new azure_functions/dotnet_extension.md page. The rename here will break the existing docs link until both land.

Test plan

🤖 Generated with Claude Code

@Lewis-E Lewis-E changed the title fix(install): Function App slot workaround + install templates (#455) [SVLS-9100] fix(install): Function App slot workaround + install templates (#455) May 22, 2026
…cenarios (#455)

Addresses intermittent MoveDirectory failures when installing the Datadog
extension on Azure Function App deployment slots. The Functions runtime holds
file locks on C:\home\SiteExtensions\ after code deployment; setting
WEBSITE_PRIVATE_EXTENSIONS=0 as a sticky slot setting prevents this.

Changes:
- Rename ARM/ → install-templates/ (docs link update coordinated in companion PR)
- Add install-templates/install-web-app.{json,bicep} — Web App templates
- Add install-templates/install-web-app-slot.{json,bicep} — Web App slot templates
- Add install-templates/install-function-app-slot.{json,bicep} — Function App slot
  templates with WEBSITE_PRIVATE_EXTENSIONS=0 sticky setting workaround
- All templates versioned (metadata.version / // Version comment) for doc comparison
- management-scripts/extension/install-latest-extension.ps1 v2.0.0:
  - Add -SlotName parameter for slot targeting
  - Auto-detect Function Apps and apply sticky WEBSITE_PRIVATE_EXTENSIONS=0
    setting before install when -SlotName is provided
- management-scripts/extension/update-all-site-extensions.ps1 v2.0.0:
  - Add -IncludeSlots flag to enumerate and update deployment slots

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@Lewis-E
Lewis-E force-pushed the worktree-issue-455-functionapp-install branch from 9f33c3b to e94e935 Compare May 22, 2026 18:42
@Lewis-E
Lewis-E marked this pull request as ready for review May 22, 2026 18:44
@Lewis-E
Lewis-E requested review from a team as code owners May 22, 2026 18:44
@Lewis-E
Lewis-E requested review from Chronobreak and removed request for a team May 22, 2026 18:44
…cleanup

- install-function-app-slot: add required existingStickyAppSettingNames param
  so slotConfigNames uses union() instead of a hard-coded single-entry list;
  deployment now fails fast rather than silently de-stickying existing settings
- install-latest-extension.ps1: remove redundant --settings call before
  --slot-settings (latter is sufficient and already additive)
- update-all-site-extensions.ps1: remove dead $slotExtensionManage in slot
  loop; add "not found" log for slots to match webapp loop behaviour
- All templates: normalize ddService/ddVersion defaults to '' (was 'my-service'
  / '0.0.0' in web-app templates, '' in function-app template)
- README: replace buried Note with fetch-before-deploy instructions and
  parameterised deploy examples

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am slightly wary of having another docs-like copy to maintain, are y'all expecting to maintain these or would that be something the onboarding team would need to do?

@Lewis-E Lewis-E May 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to use this as the test case for an auto-docs-sync AI tool, where if you update this side, it also opens a PR to update the documentation and notifies you accordingly. The work should fall on us, and I want to automate it as much as possible. This is a good test case for the similarity, since we already had a template duplicate here.

Comment thread management-scripts/extension/install-latest-extension.ps1 Outdated
Comment thread management-scripts/extension/install-latest-extension.ps1 Outdated
Comment thread management-scripts/extension/install-latest-extension.ps1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how much do we feel the need to have both bicep/ARM, or would it be okay to just use bicep and give people the command to compile it to ARM?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I was thinking of this page: https://docs.datadoghq.com/serverless/azure_app_service/windows_code?tab=armtemplate where we have both ARM and Bicep examples. I was trying to be consistent, but I would personally be fine with just bicep. Thoughts on the value of consistency?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way we'll have consistency problems, just do we want to keep the same style as the docs, or have to maintain consistency between the bicep/arm forms. Given this isn't being treated as docs (its live code), i do think just having bicep is fine but i'm not fierce on it

@ava-silver ava-silver left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by Claude

Comment thread management-scripts/extension/update-all-site-extensions.ps1 Outdated
Comment thread management-scripts/extension/install-latest-extension.ps1
Comment thread management-scripts/extension/install-latest-extension.ps1 Outdated
Comment thread management-scripts/extension/install-latest-extension.ps1
Lewis-E and others added 6 commits May 28, 2026 10:13
Stop clears file locks directly; the sticky setting then persists to ARM
and takes effect on the subsequent start — no redundant async recycle.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@Args splats the automatic variable (empty); @cmdArgs splats the
constructed argument list.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Mirrors the non-slot branch: when -ExtensionVersion is requested and
the slot is already at that version, log and break instead of proceeding
through stop/install/start.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… $baseApiUrl

-like on an array returns all matches; indexing to [0] ensures a scalar
string is used in URL construction and -replace.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@Lewis-E
Lewis-E requested a review from ava-silver May 28, 2026 18:23
@Lewis-E
Lewis-E merged commit 10afaf0 into master Jun 1, 2026
3 checks passed
@Lewis-E
Lewis-E deleted the worktree-issue-455-functionapp-install branch June 1, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Applying the DataDogSiteExtension sometimes fails on an Azure Functions Windows Application

3 participants