8000 GitHub - alexweininger/aca-vscode-tunnel: Open a VS Code tunnel into an ephemeral Azure Container Apps sandbox, optionally installing a VSIX from a PR/commit/branch/CI run. · GitHub
[go: up one dir, main page]

Skip to content

About

Open a VS Code tunnel into an ephemeral Azure Container Apps sandbox, optionally installing a VSIX from a PR/commit/branch/CI run.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

aca-vscode-tunnel

Spin up an ephemeral Azure Container Apps sandbox, install the VS Code CLI, log in with a token minted from your local az CLI, start code tunnel, and get a https://vscode.dev/tunnel/<name> link to connect — all from one command. Optionally install a VS Code extension VSIX resolved from a pull request, commit, branch, GitHub Actions run, or Azure DevOps pipeline build.

It's a throwaway, hardware-isolated cloud dev box for testing extension builds (or just for a quick remote VS Code) that you tear down when you're done.

# A plain dev box:
node bin/aca-tunnel.mjs --folder /root

# Test the extension VSIX built for PR 1234:
node bin/aca-tunnel.mjs --pr 1234
  • Cross-platform — Windows, macOS, Linux. Zero runtime dependencies (Node 18+).
  • Agent-operable — ships an AGENTS.md + Copilot skill so you can just say "open a VS Code tunnel and test PR 1234" and let Copilot run it.
  • No secrets in the link — the tunnel is private to your Azure identity. You share the tool, not the link; teammates each run it under their own login.

Prerequisites

Tool Why Install
Node 18+ runs the CLI https://nodejs.org
aca CLI drives ACA sandboxes (authenticated; aca doctor green) curl -fsSL https://aka.ms/aca-cli-install | bash (PS: iwr https://aka.ms/aca-cli-install-ps | iex)
az CLI mints the Dev Tunnels token from your login https://learn.microsoft.com/cli/azure/install-azure-cli
gh CLI only for --pr/--commit/--branch/--run GitHub sources https://cli.github.com
azure-devops az ext only for Azure DevOps sources az extension add --name azure-devops

Quick start

One-line bootstrap (brand-new machine)

Clones the repo and runs setup in a single command:

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/alexweininger/aca-vscode-tunnel/main/bootstrap.sh | bash
# Windows (PowerShell)
iwr -useb https://raw.githubusercontent.com/alexweininger/aca-vscode-tunnel/main/bootstrap.ps1 | iex

It clones into ~/aca-vscode-tunnel (override with ACA_TUNNEL_DIR) and runs the setup script. Then sign in and go:

az login && aca auth login        # one-time sign-in
gh auth login                     # only if you'll resolve VSIXes from GitHub
cd ~/aca-vscode-tunnel
node bin/aca-tunnel.mjs --folder /root

Already cloned

git clone https://github.com/alexweininger/aca-vscode-tunnel && cd aca-vscode-tunnel

./setup.sh        # macOS / Linux
./setup.ps1       # Windows

az login && aca auth login
node bin/aca-tunnel.mjs --folder /root

setup.{sh,ps1} checks prerequisites, creates aca-tunnel.config.json from the example, and installs the Copilot skill into ~/.copilot/skills/aca-vscode-tunnel.

Verify anytime with:

node bin/aca-tunnel.mjs check

Configuration

The Azure environment lives in aca-tunnel.config.json (copied from aca-tunnel.config.example.json). It is .gitignored so you never commit your subscription id. If you omit subscription/resourceGroup/sandboxGroup, the CLI falls back to your aca config (a green aca doctor) and auto-creates a group if needed.

{
  "subscription": "<your-sub-id>",          // optional; falls back to az default
  "resourceGroup": "aca-sandbox",            // optional
  "sandboxGroup": "vscode-tunnel-sandboxes", // auto-created if missing
  "location": "eastus2",                     // used only when auto-creating
  "openFolder": "/root",
  "sandbox": { "disk": "ubuntu", "cpu": "2000m", "memory": "4096Mi" },
  "source": {
    "provider": "github",                    // or "azuredevops"
    "repo": "microsoft/vscode-azureresourcegroups",
    "azureDevOps": { "org": "https://dev.azure.com/your-org", "project": "p", "pipelineId": 42, "artifact": "drop" }
  }
}

Usage

aca-tunnel [options]
aca-tunnel check            Verify prerequisites and configuration

Source (install a VSIX):
  --vsix <path|url|run-url> Local .vsix, https URL, or GitHub Actions run URL/id (repeatable)
  --pr <number>             Newest CI build VSIX for a pull request (GitHub)
  --commit <sha>            Newest CI build VSIX for a commit
  --branch <name>           Newest CI build VSIX for a branch
  --run <url|id>            GitHub Actions run to download artifacts from
  --repo <owner/repo>       Override the source repo for --pr/--commit/--branch
  --artifact <name>         Artifact name to download
  --source <github|azuredevops>

Sandbox / tunnel:
  --name <name>             Tunnel name (default: sbx-<random>)
  --folder <path>           Folder to open (e.g. /root)
  --disk / --cpu / --memory Sandbox sizing
  --group / --resource-group / --location

Output / behavior:
  --config <path>           Config file (default: nearest aca-tunnel.config.json)
  --json                    Emit a single JSON result on stdout
  --quiet                   Suppress progress logs
  --keep-on-error           Don't delete the sandbox if provisioning fails
  -h, --help

Examples

node bin/aca-tunnel.mjs --folder /root
node bin/aca-tunnel.mjs --vsix ./my-ext.vsix
node bin/aca-tunnel.mjs --pr 1234 --json
node bin/aca-tunnel.mjs --commit a1b2c3d --repo microsoft/vscode-azureresourcegroups
node bin/aca-tunnel.mjs --run https://github.com/owner/repo/actions/runs/123456789

The bare tunnel URL is printed to stdout (everything else goes to stderr), so you can capture it: LINK=$(node bin/aca-tunnel.mjs --quiet).

Using it with Copilot / agents

This repo is built to be driven by an AI agent. After setup.{sh,ps1} installs the skill, an agent can resolve the VSIX from a branch/PR/commit and run the CLI for you. Just point it at the change:

"Open a VS Code tunnel and test PR 1234." "Spin up a sandbox with the build from commit a1b2c3d and give me the link."

The agent reads aca-tunnel.config.json for the Azure environment (it will not ask you which subscription/group to use), runs node bin/aca-tunnel.mjs --json, and hands you the tunnelUrl. See AGENTS.md for the full agent guide.

How it works

  1. Mints a Dev Tunnels access token from your local az CLI (az account get-access-token --resource 46da2f7e-b5ef-422a-88d4-2a7f9de6a0b2).
  2. Creates an ACA sandbox (auto-creating the sandbox group and riding out RBAC propagation on first use).
  3. Inside the sandbox: downloads the VS Code CLI, runs code tunnel user login --provider microsoft --access-token <token>, then starts code tunnel detached.
  4. (Optional) Uploads your VSIX and installs it into the tunnel's VS Code Server so it's live the moment you connect.
  5. Prints https://vscode.dev/tunnel/<name>.

Notes & limits

  • The tunnel link is private to your Azure identity. A teammate cannot open your link — share the repo, not the URL. Each person runs it under their own login.
  • Sandboxes are ephemeral. Tear one down with aca sandbox delete --id <id> --yes (the --json output includes the exact command).
  • The login token expires in ~1h; the running tunnel keeps working. To re-authenticate, re-run code tunnel user login inside the sandbox (the CLI prints the command).
  • Azure DevOps resolution requires the azure-devops az extension and uses --branch/--commit (--pr is GitHub-only).

License

MIT

About

Open a VS Code tunnel into an ephemeral Azure Container Apps sandbox, optionally installing a VSIX from a PR/commit/branch/CI run.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0