Add 'azd ai agent code download' command#8576
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new azd ai agent code download command to the azure.ai.agents extension, enabling users to download a deployed code-based hosted agent’s source code (as a zip or extracted directory) from Azure AI Foundry, completing the deploy/download round-trip.
Changes:
- Added a new Agent API operation
DownloadAgentCodethat streams a zip download and returns response metadata (hash + agent version). - Introduced a new
codecommand group with adownloadsubcommand that downloads, verifies SHA-256, and optionally extracts with zip-slip protection. - Registered the new
codecommand group on the extension root command.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_api/operations.go | Adds a streaming download API for agent code zip + response metadata parsing. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/root.go | Registers the new code command group on the extension root. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/code.go | Implements azd ai agent code download with output handling, hash verification, and extraction logic. |
9096576 to
148c25d
Compare
Implement a new command to download the deployed source code of a code-based hosted agent from Azure AI Foundry. This completes the round-trip: azd deploy pushes code up, and this command pulls it back. - New API method DownloadAgentCode in operations.go (streaming pattern) - New 'code' command group with 'download' subcommand - Supports --version, --output, --zip flags - SHA-256 hash verification from response header - Zip-slip protection on extraction Closes Azure#8575
148c25d to
7c6887c
Compare
therealjohn
approved these changes
Jun 9, 2026
therealjohn
left a comment
Contributor
There was a problem hiding this comment.
Just add to the help text that it downloads the latest version of the agent when --version is not provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
azd ai agent code download [name]command to download deployed source code of a code-based hosted agent from Azure AI Foundryazd deploypushes code,code downloadpulls it backDetails
New API method (
operations.go):DownloadAgentCode()— streaming GET to/agents/{name}/code:download?agent_version=NCodeAgents=V1Preview,HostedAgents=V1Preview(same gate as zip upload)New command (
code.go):azd ai agent code download [name]— downloads and extracts source code--version, -v— specific version (default: latest)--dest, -d— destination path (default:./<agent-name>/or./<agent-name>.zip)--zip— save raw zip instead of extractingx-ms-code-zip-sha256response header--dest)Command registration (
root.go):codesubcommand group registered alongsidefiles,sessions,eval, etc.Note: Renamed
--output/-oto--dest/-dbecause--output/-ois a reserved azd global flag.Testing
Build & Unit Tests
go build ./...passesgo test ./internal/...)Live Testing (against real deployed agents)
All tests run against agent
hello-world-python-invocations(v1) andhello-world-voice(v7) in projectwujia-aifproject-260601(North Central US).Test 1: Download latest version (auto-extract) ✅
Extracted files:
main.py(7415B),README.md(11594B),requirements.txt(106B)Test 2: Download as zip (
--zip) ✅Zip file size: 7718 bytes. SHA-256 verified independently via
Get-FileHash— matches.Test 3: Download with
--dest✅Test 4: Download specific version (
--version 1) ✅Test 5: Error — output path already exists ✅
Test 6: Error — non-existent version (404) ✅
Test 7: Download different code agent (
hello-world-voice) ✅Extracted 9 files including
main.py,proxy.py,index.html,requirements.txt.Closes #8575