Add mandatory docker context verification for Aspire AddDockerfile services - #1673
Conversation
…kerfile services After azd init --from-code, the generated azure.yaml often omits or misconfigures docker.context for AddDockerfile() services. This adds a mandatory 3-step verification workflow to the Aspire+AZD recipe: 1. Scan AppHost for AddDockerfile calls 2. Check azure.yaml for matching docker.context entries 3. Patch azure.yaml if missing or incorrect Also updates Validation Steps to reference the new check, and bumps skill version to 1.1.2. Fixes microsoft#1660 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the azure-prepare skill documentation to ensure Aspire projects using AddDockerfile() don’t end up with missing/incorrect docker.context entries in azure.yaml after azd init --from-code, addressing the integration test failure described in #1660.
Changes:
- Bumps
azure-prepareskill version to 1.1.2. - Adds a mandatory post-init workflow to verify and patch
docker.contextforAddDockerfile()services inazure.yaml. - Updates the Aspire recipe validation checklist to reference the new mandatory verification step.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
plugin/skills/azure-prepare/SKILL.md |
Bumps skill metadata version to reflect the documentation update. |
plugin/skills/azure-prepare/references/recipes/azd/aspire.md |
Adds mandatory post-init verification/patch steps for docker.context and links it from the validation checklist. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
plugin/skills/azure-prepare/references/recipes/azd/aspire.md:101
- The Step 2/3
azure.yamlexamples for Dockerfile services omit fields that this repo’s other AZD examples consistently include (notablyproject:and oftenimage:for containerapp services). If an agent follows these examples when adding a missing service, they may produce an incomplete/invalid service definition. Consider includingproject: .(andimage: <name>if applicable) or explicitly stating these examples are partial and that existing required fields must be preserved.
```yaml
services:
<name>:
host: containerapp
docker:
path: <path>/Dockerfile
context: <path>
Step 3: Patch azure.yaml if docker.context is missing or wrong
If azure.yaml is missing the service, or has an incorrect/missing docker.context, use the edit tool to fix it.
Example — service missing entirely: If the AppHost has builder.AddDockerfile("ginapp", "./ginapp") but azure.yaml has no ginapp service, add it:
services:
ginapp:
host: containerapp
docker:
path: ./ginapp/Dockerfile
context: ./ginapp</details>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| metadata: | ||
| author: Microsoft | ||
| version: "1.1.3" | ||
| version: "1.1.4" | ||
| --- |
There was a problem hiding this comment.
The PR description says the skill version is bumped to 1.1.2, but this change bumps azure-prepare to 1.1.4. Please align the PR description with the actual version bump (or adjust the version here if 1.1.2 was intended) to avoid release/traceability confusion.
| Scan the AppHost source (e.g., `apphost.cs` or `Program.cs`) for `AddDockerfile` calls: | ||
|
|
||
| ```csharp | ||
| // Pattern: builder.AddDockerfile("<name>", "<context-path>"); | ||
| builder.AddDockerfile("ginapp", "./ginapp"); | ||
| // ^^^^^^ ^^^^^^^^ | ||
| // service context path (relative to AppHost dir) | ||
| ``` | ||
|
|
||
| ### Step 2: Check azure.yaml for each service | ||
|
|
||
| For **every** `AddDockerfile("<name>", "<path>")` call found in Step 1, verify the generated `azure.yaml` contains a matching service entry with `docker.context`: | ||
|
|
||
| ```yaml | ||
| services: | ||
| <name>: | ||
| host: containerapp | ||
| docker: | ||
| path: <path>/Dockerfile | ||
| context: <path> | ||
| ``` |
There was a problem hiding this comment.
Step 1 notes the AddDockerfile("<name>", "<context-path>") path is relative to the AppHost directory, but Steps 2/3 use <path> directly in azure.yaml. Elsewhere in this doc you state all azure.yaml paths are relative to the project root, so the instructions here will be wrong when the AppHost is in a subfolder (common for Aspire solutions). Update the guidance to resolve the context to a project-root-relative path (e.g., prefix with the AppHost folder) before writing docker.path/docker.context.
|
|
||
| ## ⛔ Post-Init: Verify and Fix Docker Context for AddDockerfile Services | ||
|
|
||
| > **MANDATORY** — After `azd init --from-code` completes, you **MUST** check the generated `azure.yaml` for correct `docker.context` on every `AddDockerfile()` service. `azd init` often omits or misconfigures the `docker.context` property, which causes build failures at deploy time. |
There was a problem hiding this comment.
The new mandatory note says azd init omitting docker.context “causes build failures at deploy time”, but the repo’s azure-yaml.md explicitly documents docker.context as optional (defaults to the Dockerfile directory). To avoid spreading incorrect guidance, please reword this to something accurate (e.g., azd init may generate an incorrect context for AddDockerfile() services and tests/validation expect it to be explicitly set to match the AppHost manifest).
| > **MANDATORY** — After `azd init --from-code` completes, you **MUST** check the generated `azure.yaml` for correct `docker.context` on every `AddDockerfile()` service. `azd init` often omits or misconfigures the `docker.context` property, which causes build failures at deploy time. | |
| > **MANDATORY** — After `azd init --from-code` completes, you **MUST** check the generated `azure.yaml` for correct `docker.context` on every `AddDockerfile()` service. `azd init` may omit this property or generate a value that does not match the AppHost manifest, and the expected validation/tests for these services require `docker.context` to be explicitly set correctly. |
…rvices (microsoft#1673) * Add mandatory post-init docker context verification for Aspire AddDockerfile services After azd init --from-code, the generated azure.yaml often omits or misconfigures docker.context for AddDockerfile() services. This adds a mandatory 3-step verification workflow to the Aspire+AZD recipe: 1. Scan AppHost for AddDockerfile calls 2. Check azure.yaml for matching docker.context entries 3. Patch azure.yaml if missing or incorrect Also updates Validation Steps to reference the new check, and bumps skill version to 1.1.2. Fixes microsoft#1660 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update plugin/skills/azure-prepare/references/recipes/azd/aspire.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update plugin/skills/azure-prepare/references/recipes/azd/aspire.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Problem
When the
azure-prepareskill handles Aspire projects that useAddDockerfile(), it runsazd init --from-codewhich often generates anazure.yamlmissing thedocker.contextproperty for Dockerfile-based services. The agent accepts the output without checking, causing the test assertion ondocker.contextto fail withundefined.Solution
Adds a mandatory "Post-Init: Verify and Fix Docker Context" section to
plugin/skills/azure-prepare/references/recipes/azd/aspire.mdwith a 3-step workflow:AddDockerfile("<name>", "<path>")callsazure.yamlhas a matching service entry with correctdocker.contextedittool to fixazure.yamlif the service ordocker.contextis missing/incorrectAlso updates the Validation Steps checklist to reference the new mandatory check, and bumps the skill version to 1.1.2.
Fixes #1660