Skip to content

Lightweight scale controller package for DTS backend#3387

Open
nytian wants to merge 8 commits intodevfrom
nytian/sc-pkg-dts
Open

Lightweight scale controller package for DTS backend#3387
nytian wants to merge 8 commits intodevfrom
nytian/sc-pkg-dts

Conversation

@nytian
Copy link
Collaborator

@nytian nytian commented Mar 16, 2026

As titled. This PR adds DTS backend support for the new lightweight scale controller package.

Copilot AI review requested due to automatic review settings March 16, 2026 18:04
Copy link
Contributor

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 PR adds DTS (Durable Task Scheduler) backend support to the lightweight scale controller package. It introduces a new AzureManaged scalability provider alongside the existing AzureStorage provider, enabling target-based autoscaling for the Azure Managed backend.

Changes:

  • Added AzureManagedScalabilityProvider, AzureManagedScalabilityProviderFactory, and AzureManagedTargetScaler classes implementing scale controller integration for the DTS backend.
  • Registered the new AzureManagedScalabilityProviderFactory in DI and added the Microsoft.DurableTask.AzureManagedBackend package dependency.
  • Added a new CI workflow job (dts) that runs Azure Managed scale tests using a DTS emulator Docker container, plus new unit and E2E tests.

Reviewed changes

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

Show a summary per file
File Description
src/.../AzureManaged/AzureManagedScalabilityProvider.cs New scalability provider for AzureManaged backend with target scaler and dummy scale monitor
src/.../AzureManaged/AzureManagedScalabilityProviderFactory.cs Factory that creates/caches AzureManaged providers with connection string resolution and token credential support
src/.../AzureManaged/AzureManagedTargetScaler.cs Target scaler computing worker count from task hub metrics
src/.../DurableTaskScaleConfigurationExtensions.cs Registers AzureManagedScalabilityProviderFactory in DI
src/.../Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj Adds AzureManagedBackend package reference
test/ScaleTests/DurableTaskScaleConfigurationExtensionsTests.cs Asserts AzureManaged factory is registered
test/ScaleTests/AzureManaged/AzureManagedScalabilityProviderFactoryTests.cs Unit tests for factory creation, caching, and selection
test/ScaleTests/AzureManaged/AzureManagedTargetScalerTests.cs E2E test for target-based scaling with pending orchestrations
test/ScaleTests/TestHelpers.cs Removed unused import and redundant comments
.github/workflows/validate-build-scale.yml Added DTS CI job with emulator and renamed existing job

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

Copilot AI review requested due to automatic review settings March 18, 2026 03:42
Copy link
Contributor

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

Adds Azure Managed (DTS) backend support to the Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale “lightweight scale controller” package, including DI registration, implementation types, tests, and CI workflow coverage.

Changes:

  • Register and ship an Azure Managed scalability provider + target scaler implementation.
  • Add Azure Managed-focused unit/integration tests and split CI scale-test workflow into Azure Storage vs DTS emulator runs.
  • Add Microsoft.DurableTask.AzureManagedBackend dependency to the FunctionsScale project.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/ScaleTests/TestHelpers.cs Removes unused import and trims helper comments around connection-string retrieval.
test/ScaleTests/DurableTaskScaleConfigurationExtensionsTests.cs Extends DI registration test to assert Azure Managed factory is registered.
test/ScaleTests/AzureManaged/AzureManagedTargetScalerTests.cs Adds DTS-emulator-backed test validating target-based scaling behavior.
test/ScaleTests/AzureManaged/AzureManagedScalabilityProviderFactoryTests.cs Adds unit tests for Azure Managed factory behavior, caching, and factory selection logic.
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj Adds Azure Managed backend package reference.
src/Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale/DurableTaskScaleConfigurationExtensions.cs Registers AzureManagedScalabilityProviderFactory in AddDurableTask().
src/.../AzureManaged/AzureManagedTargetScaler.cs Implements Azure Managed target scaler based on backend task hub metrics.
src/.../AzureManaged/AzureManagedScalabilityProviderFactory.cs Implements Azure Managed scalability provider factory with connection resolution + caching.
src/.../AzureManaged/AzureManagedScalabilityProvider.cs Implements Azure Managed scalability provider wiring scale monitor/target scaler.
.github/workflows/validate-build-scale.yml Splits scale tests into separate Azure Storage and DTS emulator jobs with filters.

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

Comment on lines +28 to +34
public async Task<TargetScalerResult> GetScaleResultAsync(TargetScalerContext context)
{
TaskHubMetrics metrics = await this.service.GetTaskHubMetricsAsync(default);
if (metrics is null)
{
this.logger?.LogWarning("Task hub metrics returned null from Azure Managed backend. This may indicate the DTS emulator is being used which may not support metrics. Returning 0 worker count.");
return new TargetScalerResult { TargetWorkerCount = 0 };
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we need this? seems pretty nit

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is how it was, so we are not regressing anything, right? I recommend ignoring this one.

@nytian nytian requested review from AnatoliB and cgillum March 18, 2026 16:36
Copilot AI review requested due to automatic review settings March 24, 2026 03:45
Copy link
Contributor

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

Adds Azure Managed (DTS) backend support to the FunctionsScale “lightweight scale controller” package by introducing an AzureManaged scalability provider + factory + target scaler, and wiring this into DI/tests/CI so Scale Controller can select and exercise the DTS path.

Changes:

  • Register AzureManagedScalabilityProviderFactory in AddDurableTask() and add the Microsoft.DurableTask.AzureManagedBackend dependency.
  • Add Azure Managed scalability implementation (AzureManagedScalabilityProviderFactory, AzureManagedScalabilityProvider, AzureManagedTargetScaler).
  • Add Azure Managed scale tests and update the scale-test GitHub workflow to run Azure Storage tests and DTS tests separately.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/ScaleTests/TestHelpers.cs Simplifies connection-string helpers used by scale tests.
test/ScaleTests/DurableTaskScaleConfigurationExtensionsTests.cs Verifies AzureManaged factory is registered in DI.
test/ScaleTests/AzureManaged/AzureManagedTargetScalerTests.cs Adds end-to-end-ish target-scaler validation against DTS emulator.
test/ScaleTests/AzureManaged/AzureManagedScalabilityProviderFactoryTests.cs Adds unit coverage for AzureManaged factory behavior (defaults, caching, selection).
src/.../Microsoft.Azure.WebJobs.Extensions.DurableTask.FunctionsScale.csproj Adds Azure Managed backend package reference.
src/.../DurableTaskScaleConfigurationExtensions.cs Registers AzureManaged scalability provider factory in DI.
src/.../AzureManaged/AzureManagedTargetScaler.cs Implements target-based scaling using AzureManaged backend metrics.
src/.../AzureManaged/AzureManagedScalabilityProviderFactory.cs Creates/caches AzureManaged scalability providers and resolves credentials/options.
src/.../AzureManaged/AzureManagedScalabilityProvider.cs Exposes AzureManaged target-scaler integration via ScalabilityProvider.
.github/workflows/validate-build-scale.yml Splits CI into Azure Storage scale tests vs DTS scale tests (emulator).

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

Comment on lines +112 to +121
// If a provider has already been created for this connection name, task hub, and client ID, return it.
if (this.cachedProviders.TryGetValue(cacheKey, out AzureManagedScalabilityProvider? cachedProvider))
{
this.logger.LogDebug(
"Returning cached durability provider for connection '{Connection}', task hub '{TaskHub}', and client ID '{ClientId}'",
cacheKey.Item1,
cacheKey.Item2,
cacheKey.Item3 ?? "null");
return cachedProvider;
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The cache key doesn’t include max-concurrency settings, and on a cache hit the provider/service aren’t updated with the current metadata values. If Scale Controller sends different concurrency limits over time (or across triggers) for the same connection+hub, the factory will keep using stale limits. Consider including concurrency limits in the cache key, or updating the cached provider/service settings before returning it.

Copilot uses AI. Check for mistakes.

- name: Start Azurite
run: azurite --silent --blobPort 10000 --queuePort 10001 --tablePort 10002 &

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The dts job starts Azurite but doesn’t wait for it to accept connections before running tests. This can make the DTS scale tests flaky on slower runners. Add the same readiness loop used in the azure-storage job (e.g., nc -z on port 10000 with retries) before invoking dotnet test.

Suggested change
- name: Wait for Azurite to be ready
run: |
echo "Waiting for Azurite to be ready on port 10000..."
for i in {1..30}; do
if nc -z localhost 10000; then
echo "Azurite is ready."
break
fi
echo "Azurite not ready yet. Retrying in 1 second..."
sleep 1
done
if ! nc -z localhost 10000; then
echo "::error::Azurite did not become ready in time."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines +173 to +180
catch (Exception ex)
{
// Unexpected exception types. Fall back to use connection string.
this.logger.LogWarning(
ex,
"Unexpected error while getting token credential from trigger metadata for connection '{Connection}'",
connectionName);
}
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.

3 participants