Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
azd ai agent init to scaffold a hosted agent project with the files you need to build, test, and deploy an AI agent to Microsoft Foundry. In this article, you choose a starting point and initialize the project from a template, from your own code, or against an existing Foundry project.
Prerequisites
- The Azure Developer CLI Foundry extensions installed.
- An authenticated Azure session (
azd auth login). - Contributor access on your Azure subscription.
Choose a starting point
There are three ways to begin a project. Pick the path that matches your situation.Initialize from a template
Run the interactive wizard in an empty directory and select Start new from a template:
The agent name comes from the template. The CLI creates an
azd environment named <directory>-dev and configures it with details from your selected Foundry project. Each template includes agent source code, a Dockerfile, and an azure.yaml file that acts as the unified project manifest for the azd project and hosted agent configuration.
Initialize from an azure.yaml URL
If you have a specific agent sample, point-m to the sample’s azure.yaml. The CLI adopts that file as the project manifest and downloads the referenced agent source.
Agent manifests (
agent.manifest.yaml) and standalone agent definitions (agent.yaml) are deprecated. As of the Foundry azd extensions (azure.ai.agents 1.0.0-beta.1), all hosted agent configuration lives in a single azure.yaml. See Author azure.yaml for hosted agents.-m option still accepts a legacy agent manifest URL, but current samples publish a unified azure.yaml.
Specify a model
Choose a model at init time:Choose a deploy mode
By default,azd ai agent init uses code deployment for Python and .NET projects. Code deployment uploads your source as a ZIP package. To scaffold a container-based project instead, pass --deploy-mode container:
--image and --agent-name. This option skips template and language selection, code scaffolding, Dockerfile generation, and Azure Container Registry setup.
Browse templates noninteractively
To inspect the catalog before you scaffold, or to driveazd ai agent init from a script, list the catalog:
initCommand that you copy and run in the directory you want to scaffold into.
Initialize from existing code
If you have existing Python or .NET agent code, runazd ai agent init inside the directory that already contains your code:
azure.yaml service entry around them without overwriting your code. For container deployment, it also adds a Dockerfile. Infrastructure remains bicep-less by default unless you eject infrastructure as code later.
Your agent code must meet the hosted agent runtime contract:
- Listen on port 8088.
- Serve a health probe at
GET /readiness. - Handle one of the supported protocols (
responsesorinvocations).
azd project, init detects the project and adds a new service entry to your existing azure.yaml. Use --src to specify a subdirectory:
Connect to an existing Foundry project
To manage an existing Foundry project throughazd, run the wizard and select the option to connect to an existing project. You can also skip the interactive selection by providing the project’s Azure resource ID directly:
Review what gets created
Afterinit completes, your project directory contains the following structure:
azure.yaml at the project root. During init, azd adopts or generates that file. You work with azure.yaml going forward. Infrastructure is bicep-less by default. Eject infrastructure only when you need to manage the generated IaC files directly.