Skip to content

Make App Lock timeout configurable (#982)#1213

Merged
Charles-Gagnon merged 5 commits intoAzure:mainfrom
thecrockster:thecrockster/configurableAppLockTimeout
Mar 17, 2026
Merged

Make App Lock timeout configurable (#982)#1213
Charles-Gagnon merged 5 commits intoAzure:mainfrom
thecrockster:thecrockster/configurableAppLockTimeout

Conversation

@thecrockster
Copy link
Copy Markdown
Contributor

@thecrockster thecrockster commented Feb 11, 2026

Add configurable AppLockTimeoutMs setting for the SQL trigger binding's application lock timeout. Previously hardcoded to 30 seconds, the timeout can now be configured via:

  • Sql_Trigger_AppLockTimeoutMs app setting
  • AppLockTimeoutMs property in host.json SqlOptions

The default remains 30000ms (30 seconds) with a minimum of 1000ms (1 second).

Changes:

  • Convert static AppLockStatements field to GetAppLockStatements(int) method
  • Add AppLockTimeoutMs property to SqlOptions with validation
  • Read config from app settings with SqlOptions fallback in SqlTableChangeMonitor, SqlTriggerListener, and SqlScalerProvider
  • Pass appLockTimeoutMs through ScaleMonitor/TargetScaler/MetricsProvider chain
  • Add telemetry for HasConfiguredAppLockTimeout and AppLockTimeoutMs
  • Add unit tests for new config and GetAppLockStatements method
  • Update documentation in BindingsOverview.md and TriggerBinding.md

Closes #982

Description

Please provide a detailed description. Be as descriptive as possible - include information about what is being changed,
why it's being changed, and any links to relevant issues. If this is closing an existing issue use one of the issue linking keywords to link the issue to this PR and have it automatically close when completed.

In addition, go through the checklist below and check each item as you validate it is either handled or not applicable to this change.

Code Changes

  • Unit tests are added, if possible
  • Integration tests are added if the change is modifying existing behavior of one or more of the bindings
  • New or changed code follows the C# style guidelines defined in .editorconfig
  • All changes MUST be backwards compatible and changes to the shared az_func.GlobalState table must be compatible with all prior versions of the extension
  • Use the ILogger instance to log relevant information, especially information useful for debugging or troubleshooting
  • Use async and await for all long-running operations
  • Ensure proper usage and propagation of CancellationToken
  • T-SQL is safe from SQL Injection attacks through the use of SqlParameters and proper escaping/sanitization of input

Dependencies

Documentation

  • Add samples if the change is modifying or adding functionality
  • Update relevant documentation in the docs

Add configurable AppLockTimeoutMs setting for the SQL trigger binding's
application lock timeout. Previously hardcoded to 30 seconds, the timeout
can now be configured via:
- Sql_Trigger_AppLockTimeoutMs app setting
- AppLockTimeoutMs property in host.json SqlOptions

The default remains 30000ms (30 seconds) with a minimum of 1000ms (1 second).

Changes:
- Convert static AppLockStatements field to GetAppLockStatements(int) method
- Add AppLockTimeoutMs property to SqlOptions with validation
- Read config from app settings with SqlOptions fallback in SqlTableChangeMonitor,
  SqlTriggerListener, and SqlScalerProvider
- Pass appLockTimeoutMs through ScaleMonitor/TargetScaler/MetricsProvider chain
- Add telemetry for HasConfiguredAppLockTimeout and AppLockTimeoutMs
- Add unit tests for new config and GetAppLockStatements method
- Update documentation in BindingsOverview.md and TriggerBinding.md

Closes Azure#982
@thecrockster thecrockster force-pushed the thecrockster/configurableAppLockTimeout branch from 9db206a to 91035ab Compare February 19, 2026 18:30
Comment thread src/Common/SqlOptions.cs Outdated
Comment thread src/TriggerBinding/SqlScalerProvider.cs Outdated
…ation

- Rename DefaultMinimumAppLockTimeoutMs to MinimumAppLockTimeoutMs (public const)
  to clarify it represents the minimum accepted value, not a default
- Add min-value validation in SqlScalerProvider for app-settings value
- Tighten validation in SqlTableChangeMonitor and SqlTriggerListener to
  check against MinimumAppLockTimeoutMs instead of just > 0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds configurable AppLockTimeoutMs setting for SQL trigger bindings to allow users to adjust the application lock timeout based on their specific server resource conditions. Previously hardcoded at 30 seconds, the timeout can now be configured via app settings (Sql_Trigger_AppLockTimeoutMs) or host.json (AppLockTimeoutMs in SqlOptions), with the same 30-second default and a validated minimum of 1 second.

Changes:

  • Converted static AppLockStatements field to GetAppLockStatements(int) method to accept dynamic timeout values
  • Added AppLockTimeoutMs property to SqlOptions with validation logic ensuring values are >= 1000ms
  • Updated SQL trigger components (SqlTableChangeMonitor, SqlTriggerListener, SqlScalerProvider, and metrics/scaling classes) to read configuration and pass the timeout through the call chain
  • Added telemetry tracking for HasConfiguredAppLockTimeout and AppLockTimeoutMs metrics
  • Updated documentation to explain the new configuration option

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Common/SqlOptions.cs Added AppLockTimeoutMs property with validation (min 1000ms, default 30000ms)
src/TriggerBinding/SqlTriggerConstants.cs Converted AppLockStatements static field to GetAppLockStatements(int) method
src/TriggerBinding/SqlTableChangeMonitor.cs Added config reading and telemetry for app lock timeout
src/TriggerBinding/SqlTriggerListener.cs Added config reading and app lock statements generation with configured timeout
src/TriggerBinding/SqlTriggerMetricsProvider.cs Added appLockTimeoutMs parameter and field to store generated statements
src/TriggerBinding/SqlTriggerScaleMonitor.cs Added appLockTimeoutMs parameter passed to metrics provider
src/TriggerBinding/SqlTriggerTargetScaler.cs Added appLockTimeoutMs parameter passed to metrics provider
src/TriggerBinding/SqlScalerProvider.cs Added config reading and validation for app lock timeout
src/Telemetry/Telemetry.cs Added HasConfiguredAppLockTimeout property and AppLockTimeoutMs measure
test/Unit/SqlOptionsTests.cs Added tests for AppLockTimeoutMs property validation and JSON serialization
test/Unit/TriggerBinding/SqlTriggerConstantsTests.cs Added tests for GetAppLockStatements method
test/Unit/TriggerBinding/SqlTriggerScaleMonitorTests.cs Updated test helpers to pass default app lock timeout
test/Integration/SqlTriggerBindingIntegrationTests.cs Updated metrics provider instantiation with timeout parameter
docs/TriggerBinding.md Updated documentation to mention configurable timeout
docs/BindingsOverview.md Added section documenting Sql_Trigger_AppLockTimeoutMs setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/TriggerBinding/SqlScalerProvider.cs Outdated
Comment thread test/Unit/SqlOptionsTests.cs
Comment thread src/TriggerBinding/SqlTriggerListener.cs
Comment thread src/TriggerBinding/SqlTriggerConstants.cs Outdated
Comment thread src/TriggerBinding/SqlTriggerConstants.cs Outdated
Comment thread src/TriggerBinding/SqlTriggerListener.cs
Comment thread src/TriggerBinding/SqlScalerProvider.cs Outdated
- SqlScalerProvider: Use nullable int for AppLockTimeoutMs config to
  distinguish 'not configured' from 'explicitly set to 0'
- SqlTriggerListener: Add HasConfiguredAppLockTimeout property and
  AppLockTimeoutMs measure to StartListener telemetry event
- SqlTriggerConstants: Merge duplicate XML summary doc comments on
  GetAppLockStatements method
- SqlOptionsTests: Add test for negative AppLockTimeoutMs values

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@thecrockster
Copy link
Copy Markdown
Contributor Author

@Charles-Gagnon @VasuBhog thanks for reviewing. I've applied those changes

@Charles-Gagnon Charles-Gagnon merged commit 863e16c into Azure:main Mar 17, 2026
1 check passed
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.

Make App Lock timeout configurable

4 participants