Skip to main content
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.
When you run azd ai agent init --infra or azd ai agent init --infra=bicep, the Azure Developer CLI (azd) scaffolds an infra/ directory into your project that contains Bicep templates. These templates define the Azure resources your hosted agent needs from the services declared in azure.yaml. Running azd provision deploys the templates to create the infrastructure. This article explains what those templates provision and how to customize them.

What gets provisioned

By default, azd ai agent init doesn’t create infrastructure-as-code files. Use --infra or --infra=bicep to add Bicep infrastructure. Use --infra=terraform to add Terraform infrastructure and set infra.provider: terraform. When you add Bicep infrastructure, the templates are based on the azd-ai-starter-basic repository and create the following Azure resources: The templates create more resources conditionally, based on the services and dependencies declared in azure.yaml:
  • Capability host — supports hosted agent deployment on the Foundry project. Created when you need custom storage of conversations.
  • Grounding with Bing or Grounding with Bing Custom Search — for the web search tool.
  • Azure AI Search — for search grounding.
  • Azure Storage — for file operations.

Project structure

How parameters flow

The main.parameters.json file maps azd environment variables to Bicep parameters:
During azd provision, azd resolves these ${VAR} references from the environment (.azure/<env>/.env) and passes them to the Bicep deployment. Outputs from the deployment, such as the Foundry project endpoint, model deployment name, and container registry endpoint, are written back to the environment for use by azd deploy, azd ai agent run, and the azd ai resource commands.

Existing resources

The Bicep templates support connecting to existing Azure resources instead of creating new ones. This is useful when your team already has shared infrastructure. Set these variables with azd env set before you run azd provision.

Customize the infrastructure

The infra/ directory is standard azd infrastructure, so you have full control over it. To add or change resources:
  1. Edit infra/main.bicep or add new modules under infra/core/.
  2. Add new parameters to main.parameters.json with ${VAR} bindings.
  3. Set the corresponding azd environment variables with azd env set.
  4. Run azd provision to apply the changes.
Changes to the Bicep files persist across deployments.

Region restrictions

The main.bicep template restricts location to regions where hosted agents are supported. If you need to deploy to a region that isn’t in the allowed list, update the @allowed decorator in main.bicep.