Support configurable scheduler token audiences and government defaults - #806
Conversation
Add ResourceId connection-string support and independent AuthorityHost forwarding. Preserve audience selection through DI, token refresh, and sandbox registration, with recording-credential regressions and government-cloud documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR updates Azure Managed client/worker configuration to treat ResourceId as a normalized token audience with region-based defaults (including a behavior change for gov/DoD regions) and adds optional AuthorityHost support for SDK-created Azure Identity credentials, with expanded shared authentication test coverage and documentation.
Changes:
- Normalize
ResourceIdtoken audience handling with per-options-instance defaults, plus explicit-copy behavior for channel recreation/reconnect scenarios. - Add
AuthorityHostparsing to connection strings and flow it into Azure Identity credential options where applicable. - Add shared and sandbox authentication tests, and document the new behavior (README, release notes, changelog).
| File | Description |
|---|---|
| test/Worker/AzureManaged.Tests/Worker.AzureManaged.Tests.csproj | Includes shared auth test code and defines SCHEDULER_WORKER to compile worker-specific shared tests. |
| test/Worker/AzureManaged.Tests/SandboxAuthenticationTests.cs | Adds worker sandbox registration/auth reconnect tests validating audience + token cache behavior. |
| test/Worker/AzureManaged.Tests/DurableTaskSchedulerWorkerOptionsTests.cs | Updates tests for new default ResourceId behavior (no longer fixed to durabletask.io). |
| test/Worker/AzureManaged.Tests/DurableTaskSchedulerWorkerExtensionsTests.cs | Updates extension tests for new default ResourceId behavior. |
| test/Shared/AzureManaged/SchedulerAuthenticationTests.cs | Adds shared authentication tests (client/worker via #if) and a local gRPC test server & credential recorder. |
| test/Shared/AzureManaged.Tests/DurableTaskSchedulerConnectionStringTests.cs | Adds tests for AuthorityHost preservation/validation in connection string credential option creation. |
| test/Client/AzureManaged.Tests/SandboxAuthenticationTests.cs | Adds client sandbox management/auth tests validating audience + token cache behavior. |
| test/Client/AzureManaged.Tests/DurableTaskSchedulerClientOptionsTests.cs | Updates tests for new default ResourceId behavior. |
| test/Client/AzureManaged.Tests/DurableTaskSchedulerClientExtensionsTests.cs | Updates extension tests for new default ResourceId behavior. |
| test/Client/AzureManaged.Tests/Client.AzureManaged.Tests.csproj | Includes shared auth test code for the client test project. |
| src/Worker/AzureManaged/RELEASENOTES.md | Documents ResourceId normalization/default behavior change and AuthorityHost support. |
| src/Worker/AzureManaged/DurableTaskSchedulerWorkerOptions.cs | Implements per-instance default ResourceId, normalization, AuthorityHost credential options forwarding, and copy semantics. |
| src/Worker/AzureManaged/DurableTaskSchedulerWorkerExtensions.cs | Ensures ResourceId is copied from connection options when configuring via extensions. |
| src/Worker/AzureManaged.Sandboxes/DurableTaskSchedulerSandboxWorkerExtensions.cs | Documents shared audience behavior for worker + sandbox registration. |
| src/Shared/AzureManaged/DurableTaskSchedulerResourceId.cs | Adds shared default resolution + normalization for token audience URIs. |
| src/Shared/AzureManaged/DurableTaskSchedulerConnectionString.cs | Adds connection-string ResourceId property and AuthorityHost-aware credential options creation. |
| src/Client/AzureManaged/RELEASENOTES.md | Documents ResourceId normalization/default behavior change and AuthorityHost support. |
| src/Client/AzureManaged/DurableTaskSchedulerClientOptions.cs | Mirrors worker changes for client options (per-instance default, normalization, copy semantics, authority host forwarding). |
| src/Client/AzureManaged/DurableTaskSchedulerClientExtensions.cs | Ensures ResourceId is copied from connection options when configuring via extensions. |
| src/Client/AzureManaged.Sandboxes/SandboxActivitiesClientServiceCollectionExtensions.cs | Documents that sandbox management reuses the configured client channel/audience. |
| samples/on-demand-sandbox/README.md | Adds guidance for gov cloud audience + authority configuration. |
| README.md | Adds comprehensive documentation on token audiences, gov defaults, normalization, and AuthorityHost. |
| CHANGELOG.md | Captures behavior change and new connection-string support. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Visual overview: configurable token audiencesPurpose: support custom and government-cloud token audiences consistently across clients, workers, and sandbox management/registration without changing the service endpoint or credential authority implicitly.
Illustration generated with Microsoft Copilot and reviewed against this PR. Scope behavior was verified with recording credentials and local gRPC servers, not live cloud authentication. |
Use atomic token issuance to select the first expiring or refreshable token, cover concurrent requests, and explain the sandbox registration stream drain. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@microsoft-github-policy-service rerun |
halspang
left a comment
There was a problem hiding this comment.
A few comments, mostly I'm concerned about the potential behavioral change. Behavioral changes tend to mean breaking changes.
It seems to me, like the breaking change here, would be that a user who hasn't explicitly set this but has their workers in a usgov region but pointing at a public scheduler would break? This seems unlikely but it's not impossible. However, is this a supported case in the gov regions? Can they call out to standard prod resources?
That is not a breaking change because it is simply unsupported invalid behavior. Clouds are intended to be siloed. Using a DTS scheduler homed in public cloud from Government Cloud for example would make it impossible to use any auth except hardcoded client key / secret (or cert) taken from public cloud but somehow injected into the Government cloud instance. In Government cloud it is the expectation that all Azure services use login.microsoftonline.us and the service principals for Microsoft owned apps available to Government cloud. The |
Restore all default-audience assertions with isolated public, government, and DoD cases. Align the changelog and compatibility documentation with supported same-cloud deployments and move the scope suffix constant to class scope. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>



Summary
What changed?
DurableTaskSchedulerClientOptions.ResourceIdandDurableTaskSchedulerWorkerOptions.ResourceIdproperties with shared normalization and per-options-instance defaults. No constructor or overload signatures change.ResourceIdconnection-string configuration for all authentication types, including forwarding through named client/worker builders. Preserve already-normalized values when copying options so meaningful repeated/.defaultURI segments are not stripped twice.https://durabletask.azure.usfor missing/null/empty audiences whenREGION_NAMEstarts withusgovorusdod, case-insensitively; retainhttps://durabletask.iootherwise. Explicit audiences always win.AuthorityHostconnection-string forwarding for SDK-created credentials that support it; omission preserves Azure Identity's defaults and environment configuration. Managed identity and developer-tool cloud configuration remain separate.Why is this change needed?
Applications need explicit/custom audiences and correct government-cloud defaults without silently changing endpoints or credential authority. Existing
ResourceIdoptions were not normalized or forwarded from connection strings.Credential construction and authority-host rationale
The .NET SDK supports both caller-created credentials and SDK-created credentials. Credential construction from connection strings already existed before this PR; this PR does not introduce that ownership model.
UseDurableTaskScheduler(endpointAddress, taskHubName, credential, ...)or settingoptions.CredentialUseDurableTaskScheduler(connectionString, ...)/DurableTaskSchedulerClientOptions.FromConnectionString(...)AuthenticationAuthorityHostis passed into supported Azure Identity credential options before construction.UseSandboxWorker()ManagedIdentityCredentialEvidence at this PR's implementation commit:
DefaultAzureCredential,ManagedIdentityCredential,WorkloadIdentityCredential,EnvironmentCredential,AzureCliCredential,AzurePowerShellCredential,VisualStudioCredential,VisualStudioCodeCredential, andInteractiveBrowserCredential;Authentication=Nonereturns null.AuthorityHostonly for an explicit nonempty connection-string value. Omission preserves Azure Identity defaults, includingAZURE_AUTHORITY_HOSTwhere applicable.Therefore the optional connection-string authority support is retained. No SDK authority property is added for caller-supplied credentials. Managed identity, Azure CLI, Azure PowerShell, and anonymous authentication do not receive this authority override; developer tools may need their own cloud configuration. Neither
ResourceIdnorREGION_NAMEsets an authority or endpoint.Issues / work items
Compatibility
This is not a breaking change to supported usage. Public-cloud deployments retain their existing default. Government/DoD deployments now select the audience registered in their cloud instead of the public-cloud audience. Calling a public-cloud scheduler from government cloud is not a supported scenario because the clouds are isolated; it is not an existing supported behavior that this PR must preserve. No migration is required for supported deployments.
Explicit audiences still take precedence regardless of
REGION_NAME; this does not enable cross-cloud scheduler access. Explicit values are normalized, and whitespace-only or empty-after-normalization values produce actionable argument errors. The service endpoint and credential authority remain independently configured.Existing property and constructor signatures remain intact; the setter's nullability annotation is widened. Orchestration replay, serialization, protobuf fields, and token-cache implementation are unchanged.
Project checklist
CHANGELOG.mdand both AzureManagedRELEASENOTES.mdfilesAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (agent verification completed; final human approval pending):
Testing
Automated tests
REGION_NAME=UsGovVirginia(393 repeat executions).REGION_NAMEand use the existing nonparallel environment collection.dotnet format style --no-restore --verify-no-changeschecks passed for the changed source and tests; build-time .NET/StyleCop analyzers ran.FINALNEWLINE: the existing.editorconfigrequiresinsert_final_newline=false, while StyleCop requires a final newline. Existing final-newline conventions were retained rather than changing unrelated repository configuration.git diff --checkpasses withcore.whitespace=cr-at-eol, preserving the changelog's existing CRLF format.GetReleaseNotespackaging target reads both AzureManagedRELEASENOTES.mdfiles intoPackageReleaseNotes; these files remain in use despite their stale historical entries.Manual validation (only if runtime/behavior changed)
TokenCredential.GetTokenAsync; loopback gRPC servers exercise the configured client/worker channels and sandbox management/registration transports.Notes for reviewers