Repository navigation
feat: allow kosli snapshot azure target other Azure clouds and endpoints - #1331
Merged
Merged
Conversation
Contributor
|
Claude finished @mbevc1's task in 3m 2s —— View job Follow-up review complete
All three previously-raised findings are resolved and their review threads are already marked resolved on GitHub:
No new bugs, security issues, or regressions found in the reviewed commits. Full details posted as a summary comment. |
Contributor
Author
|
The Kudu token no longer changes on the default path. Default path (public cloud, no overrides) compared with
|
mbevc1
force-pushed
the
20261104_feat_azure_endpoints
branch
from
November 4, 2026 18:26
490c992 to
9946211
Compare
gsavage
approved these changes
Nov 5, 2026
mbevc1
force-pushed
the
20261104_feat_azure_endpoints
branch
from
November 5, 2026 10:50
528d917 to
9cf9f8b
Compare
snapshot azure could only authenticate against the Azure public cloud, so a tenant in Azure China or Azure Government failed before reaching its registry, even though the ACR login-server check already accepts .azurecr.cn and .azurecr.us. --azure-cloud (public, china, usgov; default public) selects the SDK's cloud configuration and passes it to the client secret credential, the App Service client factory and the ACR client, so all three use the same authority, Resource Manager and registry audience.
The zip-deployed app path fetched its Kudu bearer token with a hand-written v1 client-credentials request to login.microsoftonline.com, so it ignored the cloud the rest of the command now uses and kept a second copy of the authority. The token now comes from GetToken on the credential the App Service client factory already holds, with the Resource Manager audience of the chosen cloud, formed as the ARM SDK forms its own scope. The token request also gains the SDK's retries and caching.
The package of a zip-deployed app was downloaded from <app>.scm.azurewebsites.net, a suffix that only exists in the public cloud, so the download failed in Azure China and Azure Government. The host is now the site's own Repository entry in hostNameSslStates, which Resource Manager returns for every cloud. A site without one fails with a message naming the app rather than guessing a host. The download also goes through the same transport as the SDK clients.
--azure-cloud covers the three sovereign clouds, but a private cloud or a local stand-in has endpoints of its own, and an end-to-end test in another process cannot reach the CLI's Go test seams. --azure-authority-host and --azure-resource-manager-url (or KOSLI_AZURE_AUTHORITY_HOST and KOSLI_AZURE_RESOURCE_MANAGER_URL) replace the chosen cloud's endpoints in a copy of its configuration, keeping its token audiences. Both must be https URLs, which the SDK requires for an authority and for any endpoint it sends a bearer token to. Instance discovery is turned off when the authority is overridden, because it asks the public cloud about the new authority. A test drives the whole snapshot against a TLS stand-in named only by the overrides: token, site list and Kudu download.
Two parts of the default public-cloud path had changed with the new cloud selection: - The credential was always given a cloud, so azidentity stopped honouring AZURE_AUTHORITY_HOST, which it reads only when no cloud is set. The public cloud with no authority override now leaves the cloud unset for the credential, as before. - The Kudu token was requested for https://management.core.windows.net/ instead of https://management.azure.com/, the resource the real-Azure integration tests have always used. The public cloud asks for that resource again. Azure China and Azure Government ask for their management.core resources, which the Azure CLI sends to Kudu there. The test stand-in now answers instance discovery for the authority named in the request, as Entra does, so a non-default authority can be tested.
Taking the Kudu host from the site's host names meant the Resource Manager token went to whatever Repository host the site listed. Before, it only ever went to <app>.scm.azurewebsites.net. Unless --azure-resource-manager-url replaces the site list, the host must now be the app's own SCM host in the chosen cloud's App Service domain: <app>.scm.<domain>, or <app>-<hash>.scm.<region>.<domain> for an app with a unique default hostname. Anything else fails before a token is requested. App Service Environment hosts stay unsupported, as before.
acrImageFingerprint built a new client secret credential for every image, and each credential has its own token cache, so every ACR app cost a fresh Entra token request. A client made by NewAzureClient now lends its credential to the ACR arm; a client built without one, as in the ACR tests, still gets a new one. The real-Azure zip test's "unknown" case now asserts the failure it reaches, a site with no Kudu host name, rather than any error.
mbevc1
force-pushed
the
20261104_feat_azure_endpoints
branch
from
November 5, 2026 10:51
9cf9f8b to
2725319
Compare
Contributor
Follow-up review (commits through 2725319)Checked the three previously-raised findings against the current code (all three GitHub threads are already marked resolved):
No new bugs, security issues, or regressions found in the lines touched by these commits — 0 new inline comments. |
gsavage
approved these changes
Nov 5, 2026
dangrondahl
pushed a commit
to kosli-dev/docs
that referenced
this pull request
Nov 6, 2026
Marks Azure apps as supporting include/exclude by name and regex in the snapshotting scopes table (GA: released in CLI v2.54.0). Based on [feat: add include and exclude name filters to kosli snapshot azure](kosli-dev/cli#1328) and [feat: allow kosli snapshot azure target other Azure clouds and endpoints](kosli-dev/cli#1331). Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
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.
Let
kosli snapshot azurerun against Azure China, Azure Government, a private cloud or a local stand-in. Its login, Resource Manager and Kudu endpoints were fixed to the public cloud, so sovereign-cloud tenants could not use it, and Cloud Capture's end-to-end job could not run the real CLI against its Azure stand-in.Closes #1327
New flags
--azure-cloud(public,china,usgov; defaultpublic)--azure-authority-hostand--azure-resource-manager-url, also settable asKOSLI_AZURE_AUTHORITY_HOSTandKOSLI_AZURE_RESOURCE_MANAGER_URLBehaviour changes for existing users
With the default
publiccloud and no overrides, the endpoints, token audiences and authority are the same as onmain. What changes:https://management.azure.com/, but through the SDK credential (Entra v2 endpoint, cached and retried) instead of a hand-written v1 request that panicked on a missingaccess_token. The real-Azure integration tests download from Kudu with it and pass.Repositoryentry inhostNameSslStates, the same lookup the Azure CLI uses. The token is sent only if that host is the app's own SCM host:<app>.scm.azurewebsites.net, or<app>-<hash>.scm.<region>.azurewebsites.netfor an app with a unique default hostname. Such apps did not work before. A site that lists no such host fails, naming the app, before any token is requested. App Service Environment hosts stay unsupported, as before.AZURE_AUTHORITY_HOST: still honoured, and now also for the Kudu token, which always went tologin.microsoftonline.combefore.Design choices
management.core.chinacloudapi.cn/ormanagement.core.usgovcloudapi.net/, the resources the Azure CLI sends to Kudu there. Neither cloud has been tested against real Azure.--azure-resource-manager-urlalso lifts the Kudu host check, because the site list then comes from the operator's own endpoint.Cloud Capture
Set the two environment variables in the Snapshotter to the stand-in's https URL. The stand-in has to serve:
/<tenant>/v2.0/.well-known/openid-configurationand the token endpoint it namesRepositoryhost name, which may be the stand-in's own host/api/zip/site/wwwroot/Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR (not needed)