Add sovereign cloud support (GCCH, DoD, China)#352
Draft
rajan-chari wants to merge 3 commits intomainfrom
Draft
Conversation
- Add Startup section to CLAUDE.md with knowledge file loading, session context, private notes support, and quick-start commands - Add Lessons Learned section to CLAUDE.md for persistent knowledge - Create Claude-KB.md for cross-session learning - Add session-context.md and *-private.md to .gitignore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce CloudEnvironment class that bundles all cloud-specific service endpoints, with predefined instances for Public, USGov (GCCH), USGovDoD, and China (21Vianet). Thread the cloud environment through ClientCredentials, token clients, validation settings, and DI host builders so that all previously hardcoded endpoints are now configurable per cloud. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Manual Test ResultsTested locally by linking a scaffolded C# echo bot to this branch via Environment
Tests
ObservationThe config path ( Tested with teams-sdk-dev tooling. |
Allow users to override specific CloudEnvironment endpoints (e.g. LoginEndpoint, LoginTenant) via appsettings.json, enabling scenarios like China single-tenant bots that require a tenant-specific login URL. - Add CloudEnvironment.WithOverrides() for layering nullable overrides - Add 8 endpoint override properties + ResolveCloud() helper to TeamsSettings - Unify cloud resolution across Apply(), AddTeamsCore(), and AddTeamsTokenAuthentication() - Add WithOverrides unit tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Updated Test Results (after
|
| # | Test | Result |
|---|---|---|
| 1 | Invalid cloud name ("Cloud": "Narnia") |
Pass. Crashes with: Unknown cloud environment: 'Narnia'. Valid values are: Public, USGov, USGovDoD, China. |
| 2 | Default behavior (no Cloud key) | Pass. Bot starts, echoes messages. Defaults to CloudEnvironment.Public. |
| 3 | Named preset ("Cloud": "Public") |
Pass. Starts normally. |
| 4 | Single endpoint override ("TokenServiceUrl": "https://bogus.example.com/token") |
Pass. Bot starts (override accepted at startup, used at runtime). Proves individual override is wired through ResolveCloud → WithOverrides. |
| 5 | Preset + override ("Cloud": "USGov" + "LoginEndpoint": "https://custom-login.example.com") |
Pass. Bot starts with USGov as base and the custom LoginEndpoint applied on top. |
| 6 | Unit tests (CloudEnvironmentTests) |
Pass. All 21 tests pass, including 4 new WithOverrides tests (all-nulls, single, multiple, all overrides). |
Design Notes
WithOverridesreturnsthiswhen all overrides are null — nice zero-allocation fast path.ResolveCloudchains cleanly: programmaticAppOptions.Cloud→ config"Cloud"preset →Publicfallback → per-endpoint overrides. Priority order is clear.- All 8 endpoint properties are individually overridable from
appsettings.jsonunder theTeamssection.
Contributor
Author
URL Verification: CloudEnvironment presets vs Bot Framework docsCross-referenced all USGov (GCCH)
USGovDoD
Notes on the two
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CloudEnvironmentclass (Microsoft.Teams.Api.Auth) bundling all cloud-specific service endpoints with predefined static instances:Public,USGov(GCCH),USGovDoD, andChina(21Vianet)ClientCredentials,BotTokenClient,UserTokenClient,BotSignInClient,App,TeamsValidationSettings, and DI host builders so all previously hardcoded endpoints are configurable per cloudCloudproperty toAppOptions(programmatic) andTeamsSettings(appsettings.json) for easy configurationTeamsSettings(e.g.LoginEndpoint,LoginTenant) for scenarios requiring per-endpoint customization — such as China single-tenant bots that need a tenant-specific login URLUsage
Named cloud preset (appsettings.json):
{ "Teams": { "ClientId": "...", "ClientSecret": "...", "Cloud": "USGov" } }Per-endpoint overrides (appsettings.json):
{ "Teams": { "ClientId": "...", "ClientSecret": "...", "TenantId": "your-tenant", "Cloud": "China", "LoginTenant": "your-tenant-id" } }Programmatic:
Valid cloud names:
Public(default),USGov,USGovDoD,ChinaOverride properties:
LoginEndpoint,LoginTenant,BotScope,TokenServiceUrl,OpenIdMetadataUrl,TokenIssuer,ChannelService,OAuthRedirectUrlFiles changed
Libraries/Microsoft.Teams.Api/Auth/CloudEnvironment.csTests/Microsoft.Teams.Api.Tests/Auth/CloudEnvironmentTests.csLibraries/Microsoft.Teams.Api/Auth/ClientCredentials.csLibraries/Microsoft.Teams.Api/Clients/BotTokenClient.csLibraries/Microsoft.Teams.Api/Clients/UserTokenClient.csLibraries/Microsoft.Teams.Api/Clients/BotSignInClient.csLibraries/Microsoft.Teams.Apps/AppOptions.csLibraries/Microsoft.Teams.Apps/App.csTeamsSettings.cs(Extensions.Configuration) — endpoint override properties +ResolveCloud()HostApplicationBuilder.cs(Extensions.Hosting) — unified cloud resolution viaResolveCloud()HostApplicationBuilder.cs(Plugins.AspNetCore) — unified cloud resolution viaResolveCloud()TeamsValidationSettings.cs(Plugins.AspNetCore)Test plan
dotnet build— 0 errorsdotnet test— all existing + new tests passCloudEnvironment.PublicURLs match current hardcoded values (backward compat)WithOverrides()with all nulls returns same instance (no allocation)CloudEnvironment.USGovURLs match BF GCCH docsCloudEnvironment.ChinaURLs match BF China docsSamples.Echo) starts correctly with no cloud config (defaults to Public)🤖 Generated with Claude Code