microsoft / microsoft/GitHub-Copilot-for-Azure

Replace azure-deploy skill azd environment loading with a script

Open
#2,514 1 comment 0 reactions 1 assignee View on GitHub

@tmeschter is already working on this.

Since Jul 13, 2026.

azure-deploy skills
Dominant language
Python
Stars
250
Forks
204
Avg merge
1d 12h
Merged PRs (30d)
67

Description

## Summary

Copilot has identified a portion of a skill that is a good candidate for replacement with a script.

The candidate is the **`azd env get-values` environment-loading step** in the `azure-deploy` skill — a fixed transform that runs `azd env get-values`, splits each line on the first `=`, and exports the result into the shell environment. It is repeated in at least four files.

## Candidate description

Many AZD post-deploy steps need the deployment's environment variables loaded into the shell before they can run (SQL grants, endpoint checks, migrations). The skill does this with the same mechanical transform everywhere:

- **bash:** `eval $(azd env get-values)` — or a safer per-line `while IFS='=' read ...` loop.
- **PowerShell:** `azd env get-values | ForEach-Object { $k,$v = $_ -split '=',2; Set-Item "env:$k" $v }`.

This is a strong script candidate because it is:
- **Repeated verbatim across at least four files** (`recipes/azd/verify.md`, `post-deployment.md`, `sql-managed-identity.md`, `ef-migrations.md`), in both bash and PowerShell forms.
- **A pure, deterministic transform** — no branching, no judgment; load once, export.
- **A correctness/safety fix** — several copies use the fragile/unsafe `eval $(...)` idiom (which mishandles values containing spaces or shell metacharacters), while `ef-migrations.md` already advertises a script that "loads `azd env get-values` safely (no `eval`)." Consolidating to one hardened helper removes the foot-gun in one place.

**Sketch — `load-azd-env.{sh,ps1}`:**
- **Input:** optional `--environment` (defaults to the current `azd` env).
- **Output:** exports each `KEY=VALUE` safely into the environment and prints a compact summary (e.g. `Loaded 12 variables from azd env `), so the agent knows the load succeeded without echoing secrets.

> Choosing *which* loaded variable holds the relevant app/identity/service name is a parameter the caller supplies — not logic the helper needs.

## Affected file and lines

- [`references/recipes/azd/verify.md` — load environment variables (L84–L102)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-deploy/references/recipes/azd/verify.md#L84-L102)
- [`references/recipes/azd/post-deployment.md` — get app identity from azd env (L37–L51)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-deploy/references/recipes/azd/post-deployment.md#L37-L51)
- [`references/recipes/azd/sql-managed-identity.md` — load azd env (L34–L37)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-deploy/references/recipes/azd/sql-managed-identity.md#L34-L37)
- [`references/recipes/azd/ef-migrations.md` — safe `azd env get-values` loading referenced by hook script (L83)](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/3890cbfb65c548ce8daa96cabd1d8de63f7bbcca/plugin/skills/azure-deploy/references/recipes/azd/ef-migrations.md#L83)

## Next steps

1. **Evaluate the candidate** — confirm the steps are stable and parameterizable, and that the script captures everything the skill needs.
2. **Create both a bash _and_ a PowerShell version** of the script so the skill works across platforms.
3. **Run integration tests** to verify the scripts behave correctly and the skill still completes end-to-end.

## Background Information

### Why replace regular steps with scripts

Replacing a regular, well-defined series of steps with a script can:

- **Reduce token usage** — the skill no longer needs to spell out each command and parse large command output inline; the agent invokes one script and reads a compact result.
- **Improve reliability** — the logic is written and tested once, instead of being re-derived by the agent on every run.
- **Improve determinism** — the same inputs always produce the same steps and output, removing run-to-run variation.
- **Improve speed of execution** — a single script call replaces multiple round-trips of command generation, execution, and large-output parsing.

### Authoring notes for the scripts

- **Reference scripts with markdown links**, not just a bare path to the script file.
- **Include examples** in the skill showing how to run each script (sample invocation with arguments).
- **Briefly explain what each script does** where it is referenced.
- **The script output should explain what it did**, so the agent and user can understand the result without re-inspecting raw command output.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.