Skip to content

feat(health): scope storage check to script host - #11927

Open
Jacob Viau (jviau) wants to merge 4 commits into
devfrom
u/jviau/move-storage-health-check
Open

Jacob Viau (jviau) wants to merge 4 commits into
devfrom
u/jviau/move-storage-health-check

Conversation

@jviau

@jviau Jacob Viau (jviau) commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Issue describing the changes in this PR

resolves #11636

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Backport PR to follow
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Moves WebJobsStorageHealthCheck into the ScriptHost service scope. Placeholder hosts skip JobHost health-check registration entirely. For active hosts, storage registration is deferred through HealthCheckServiceOptions so it evaluates the final DI-provided IConfiguration and registers only when AzureWebJobsStorage has a non-empty scalar or hierarchical configuration value.

The health check no longer depends on WebHost-only state, supports both synchronous and asynchronous disposal to match ScriptHost lifetime management, and has end-to-end coverage for configured storage and placeholder hosts.

Copilot AI lite review requested due to automatic review settings August 17, 2026 21:15
@jviau
Jacob Viau (jviau) requested a review from a team as a code owner August 17, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts how the WebJobsStorageHealthCheck is registered and scoped so that it only runs when AzureWebJobsStorage is actually configured, avoiding false “unhealthy” results for apps (e.g., Service Bus–only) that don’t require Storage. It also moves the storage health check into the ScriptHost/JobHost DI scope so it participates correctly in ScriptHost lifetime and disposal.

Changes:

  • Introduces IConfiguration.IsPlaceholderModeEnabled() and uses it to gate registration in placeholder mode.
  • Adds AddJobHostScopedHealthChecks(IConfiguration) to conditionally register WebJobsStorageHealthCheck only when storage configuration is present (scalar or hierarchical).
  • Updates WebJobsStorageHealthCheck to remove WebHost-only dependencies and support both IDisposable and IAsyncDisposable, with corresponding test updates.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/WebJobs.Script.Tests/Extensions/ConfigurationExtensionsTests.cs Adds unit tests for the new IConfiguration.IsPlaceholderModeEnabled() helper.
test/WebJobs.Script.Tests/Diagnostics/HealthChecks/WebJobsStorageHealthCheckTests.cs Updates storage health check tests to match the simplified constructor and removed WebHost-only behaviors.
test/WebJobs.Script.Tests/Diagnostics/HealthChecks/HealthCheckExtensionsTests.cs Adds coverage for conditional JobHost-scoped storage health check registration and sync disposal behavior.
src/WebJobs.Script/ScriptHostBuilderExtensions.cs Registers JobHost-scoped health checks during ScriptHost service configuration.
src/WebJobs.Script/Environment/ConfigurationExtensions.cs Adds IConfiguration placeholder-mode detection used for registration gating.
src/WebJobs.Script/Diagnostics/HealthChecks/WebJobsStorageHealthCheck.cs Removes placeholder/ScriptHostManager dependencies and adds sync + async disposal support.
src/WebJobs.Script/Diagnostics/HealthChecks/HealthCheckExtensions.cs Moves storage check registration behind new JobHost-scoped conditional registration API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jviau
Jacob Viau (jviau) force-pushed the u/jviau/move-storage-health-check branch from 425cfa1 to 7d87f54 Compare August 20, 2026 16:47
Register the WebJobs storage health check only for active, non-placeholder script hosts with configured storage.
Resolve the final ScriptHost configuration through health check options and register the storage check only when storage is configured. Skip JobHost health-check services entirely for placeholder hosts and cover both paths end to end.
@jviau
Jacob Viau (jviau) force-pushed the u/jviau/move-storage-health-check branch from a2538bb to 7f78cf0 Compare August 27, 2026 16:43
Comment thread src/WebJobs.Script/ScriptHostBuilderExtensions.cs
Comment thread src/WebJobs.Script/ScriptHostBuilderExtensions.cs Outdated
Use the per-host standby configuration snapshot when registering health checks and prevent WebHost publishers from flowing into the JobHost child container.
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.

WebJobsStorageHealthCheck causing warnings (unhealthy container) when a AzureWebJobsStorage is not configured

3 participants