-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add az CLI shim for Azure token acquisition via ado-codespaces-auth #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 an Azure CLI (az) shim that intercepts az account get-access-token commands to enable Azure SDK authentication in GitHub Codespaces without requiring manual az login. The shim delegates token acquisition to the azure-auth-helper from the ado-codespaces-auth VS Code extension.
Changes:
- Added new
azCLI shim script that intercepts access token requests and falls back to the real Azure CLI for other commands - Integrated the az shim into the artifacts-helper feature with a configurable
azAliasoption - Updated documentation to describe the az shim functionality and usage
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/artifacts-helper/scripts/az | New shim script that intercepts az account get-access-token and delegates to azure-auth-helper |
| src/artifacts-helper/install.sh | Added ALIAS_AZ configuration option and integrated az into the shim installation process |
| src/artifacts-helper/devcontainer-feature.json | Added azAlias boolean option to control az shim installation |
| src/artifacts-helper/README.md | Updated documentation to include az shim description and corrected grammar |
| src/artifacts-helper/NOTES.md | Updated notes to include az shim functionality and corrected grammar |
Comments suppressed due to low confidence (1)
src/artifacts-helper/scripts/az:19
- The variable
$0should be quoted to handle paths containing spaces. Changedirname $0todirname "$0"to prevent word splitting issues.
source "$(dirname $0)"/resolve-shim.sh
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
markphip
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the Copilot feedback in addition to mine and either just mark items resolved or implement the suggestions it made
Summary
Adds an
azCLI shim that interceptsaz account get-access-tokenrequests and delegates toazure-auth-helperfrom the ado-codespaces-auth VS Code extension. This enables Azure SDK'sDefaultAzureCredential(viaAzureCliCredential) to work seamlessly in GitHub Codespaces without requiring manualaz login.Problem
When using Azure SDKs (e.g., Azure.Identity for .NET, azure-identity for Python) in Codespaces,
DefaultAzureCredentialfails because:az logintimes out waiting for browser-based authenticationAzureCliCredentialfalls back to callingaz account get-access-token --resource <url>, which also failsThis blocks local development of services that access Azure resources like Key Vault, Storage, or ARM.
Solution
The shim:
az account get-access-tokencommands--resource,--scope, or--resource-typeparameterhttps://vault.azure.net/.default)~/azure-auth-helper get-access-token "<scope>"to acquire a token via IPC to VS CodeazCLI output formatazCLI for all other commandsFeatures
--resource <url>(v1.0 endpoint style)--scope <scope>(v2.0 endpoint style)--resource-typewith well-known mappings (arm, ms-graph, aad-graph, batch, data-lake, media, oss-rdbms)ACTIONS_ID_TOKEN_REQUEST_URL)Testing
Tested with:
az account get-access-token --resource https://vault.azure.net✅az account get-access-token --resource-type arm✅az account get-access-token --scope https://graph.microsoft.com/.default✅DefaultAzureCredential→ Key Vault access ✅