Azure / Azure/azure-dev

[Feature] Expose the target service name to global predeploy/postdeploy hooks

Open
#9,251 7 comments 0 reactions 1 assignee Claimed by @vhvb1989 View on GitHub
area/hooks enhancement
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

### Summary

Global `predeploy` / `postdeploy` hooks fire around **every** `azd deploy`, but `azd` does not tell the hook **which service** triggered the deploy. There's no standard, `azd`-provided signal naming the current target.

### Why it matters

We rely on global hooks for cross-cutting concerns that must run regardless of which service was deployed (e.g. agent RBAC + a new Foundry version, Logic App workflow `PUT`). But some of that logic must **branch per service** — e.g. only run the agent's `az acr build` when the target is the agent, only apply a slot repoint for the relevant service.

Running `azd deploy backend` vs. `azd deploy frontend` vs. `azd deploy agent-server` all invoke the *same* global `predeploy.ts` with no first-class way to know the target.

### Current workaround

We maintain our own `AZD_DEPLOY_SERVICE` env-var convention that we set/read ourselves so the global hook can branch. This is:

- **untyped / ad-hoc** — a string convention, easy to typo, invisible in `azure.yaml`
- **brittle** — can drift out of sync with what `azd` is actually deploying
- **non-discoverable** — nothing documents that the global hook secretly branches on a service name

### Ask

Provide a **standard signal** to global hooks naming the service currently being deployed — e.g. a well-known env var (`AZD_SERVICE_NAME`) set for the duration of the hook, and/or a `--service ` value surfaced consistently to global `pre/postdeploy`.

---
_Context: encountered while deploying a multi-component AI/chat service (App Service + Function App + Logic App + Foundry hosted agent) end-to-end with `azd` provision/deploy in [Azure/azure-sdk-tools `tools/sdk-ai-bots/deployment`](https://github.com/Azure/azure-sdk-tools/tree/main/tools/sdk-ai-bots/deployment). We currently work around this with a TypeScript hook._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.