Skip to content

1.7 - AZD Templates Introduction

Today we complete the provisioning journey by exploring Azure Developer CLI (AZD) templatesβ€”the most complete approach to deploying AI applications on Azure.

  • What Azure Developer CLI (AZD) is and how it differs from ARM/Bicep
  • The structure and components of an AZD template
  • How AZD templates provide a complete solution (infrastructure + application)
  • The azd workflow from init to deploy

Before diving in, review these resources:

  1. πŸ“˜ Azure Developer CLI Overview - Official AZD documentation
  2. πŸ“˜ AZD Template Gallery - Curated collection of AZD templates
  3. πŸ”— AZD GitHub Repository - Source code and examples

We’ve progressed through three scenarios:

DayAnalogyApproachCompleteness
Day 5Buy one chairManual provisioningOne resource
Day 6Buy full kitchenARM/Bicep templateInfrastructure
Day 7Hire move-in coordinatorAZD templateComplete solution

Hiring a move-in coordinator who:

  • Orders and assembles ALL furniture
  • Stocks the kitchen with essentials
  • Sets up utilities and internet
  • Configures smart home devices
  • Hangs pictures on walls
  • Leaves you with a ready-to-live-in space

You can still customize afterwards, but you start from a fully functional apartment, not an empty one!

Azure Developer CLI (azd) is a command-line tool that:

  • Provisions Azure infrastructure
  • Deploys application code
  • Configures services and connections
  • Sets up monitoring and logging
  • Provides local development workflow
  • Enables CI/CD integration

Key Insight: AZD templates are complete solutions, not just infrastructure definitions.

FeatureManualARM/BicepAZD Template
Infrastructureβœ…βœ…βœ…
App CodeβŒβŒβœ…
ConfigurationβŒβŒβœ…
Local DevβŒβŒβœ…
One CommandβŒβŒβœ…
Best PracticesβŒβš οΈβœ…
Time to DeployHours15-30 min5-10 min

An AZD template is a Git repository with this structure:

my-azd-template/
β”œβ”€β”€ azure.yaml # AZD configuration
β”œβ”€β”€ infra/ # Infrastructure as Code
β”‚ β”œβ”€β”€ main.bicep # Main infrastructure template
β”‚ β”œβ”€β”€ main.parameters.json
β”‚ └── modules/ # Reusable Bicep modules
β”‚ β”œβ”€β”€ openai.bicep
β”‚ β”œβ”€β”€ search.bicep
β”‚ └── app-service.bicep
β”œβ”€β”€ src/ # Application source code
β”‚ β”œβ”€β”€ api/ # Backend API
β”‚ β”‚ β”œβ”€β”€ app.py
β”‚ β”‚ β”œβ”€β”€ requirements.txt
β”‚ β”‚ └── Dockerfile
β”‚ └── web/ # Frontend application
β”‚ β”œβ”€β”€ package.json
β”‚ └── src/
β”œβ”€β”€ .azure/ # AZD environment data (gitignored)
β”œβ”€β”€ .devcontainer/ # Dev container configuration
β”œβ”€β”€ .github/ # GitHub Actions workflows
β”‚ └── workflows/
β”‚ └── azure-dev.yml
└── README.md # Getting started guide

Defines the template structure and deployment targets:

name: retail-ai-assistant
metadata:
template: retail-ai-assistant@0.0.1
services:
api:
project: ./src/api
language: python
host: containerapp
web:
project: ./src/web
language: typescript
host: staticwebapp
hooks:
postprovision:
- azd env set AZURE_OPENAI_ENDPOINT $(az cognitiveservices account show -g ${AZURE_RESOURCE_GROUP} -n ${AZURE_OPENAI_NAME} --query properties.endpoint -o tsv)

What it defines:

  • Template name and metadata
  • Application services (API, web, etc.)
  • Which host each service uses (Container Apps, Static Web Apps, etc.)
  • Deployment hooks for configuration

Contains Bicep files defining Azure resources:

infra/main.bicep
targetScope = 'subscription'
@minLength(1)
@maxLength(64)
@description('Name of the environment')
param environmentName string
@minLength(1)
@description('Primary location for all resources')
param location string
// Create resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'rg-${environmentName}'
location: location
}
// Deploy core services
module openai 'modules/openai.bicep' = {
scope: rg
name: 'openai'
params: {
name: 'openai-${environmentName}'
location: location
}
}
module containerApps 'modules/container-apps.bicep' = {
scope: rg
name: 'container-apps'
params: {
name: 'ca-${environmentName}'
location: location
}
}

Your actual application code:

from flask import Flask, request, jsonify
from azure.identity import DefaultAzureCredential
from azure.ai.openai import OpenAIClient
import os
app = Flask(__name__)
openai_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"]
client = OpenAIClient(openai_endpoint, DefaultAzureCredential())
@app.route("/api/chat", methods=["POST"])
def chat():
message = request.json["message"]
# Use OpenAI to generate response
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": message}]
)
return jsonify({"response": response.choices[0].message.content})

Start from a template:

Terminal window
azd init --template Azure-Samples/contoso-chat
azd init

What it does:

  • Clones template repository (if using existing)
  • Creates .azure/ directory for environment data
  • Prompts for environment name

Create Azure infrastructure:

Terminal window
azd provision

What it does:

  • Prompts for Azure subscription and region
  • Deploys Bicep templates from infra/
  • Creates all Azure resources
  • Captures outputs (endpoints, IDs, keys)
  • Stores configuration in .azure/<env>/.env

Time: 5-10 minutes

Deploy application code:

Terminal window
azd deploy

What it does:

  • Builds application code
  • Creates container images (if needed)
  • Deploys to target services (Container Apps, Static Web Apps, etc.)
  • Configures environment variables
  • Runs any post-deploy hooks

Time: 3-5 minutes

Provision + Deploy in one command:

Terminal window
azd up

This is the magic command! From zero to deployed application in ~10 minutes.

View application metrics and logs:

Terminal window
azd monitor --overview
azd monitor --logs

Opens Application Insights dashboards.

Remove all resources:

Terminal window
azd down

Deletes the resource group and all deployed resources.

βœ… Fast Start: Working application in minutes βœ… Best Practices: Security, monitoring built-in βœ… Local Development: Dev containers and local testing βœ… Familiar Tools: Use your preferred IDE and languages

βœ… Consistency: Everyone uses same setup βœ… Onboarding: New team members productive immediately βœ… Collaboration: Infrastructure as code, code reviewed βœ… Documentation: Template itself is documentation

βœ… Governance: Approved patterns and configurations βœ… Compliance: Security and compliance built-in βœ… Cost Control: Right-sized resources βœ… Auditability: Full deployment history in Git

Microsoft and community maintain templates for common scenarios:

AI & ML:

  • ChatGPT + Enterprise data (RAG)
  • Azure OpenAI + Cosmos DB
  • AI Agents with function calling
  • Document intelligence processing

Web Applications:

  • React + Node.js + PostgreSQL
  • .NET Blazor + Azure SQL
  • Python Django + Redis
  • Next.js + Cosmos DB

APIs & Microservices:

  • FastAPI on Container Apps
  • .NET minimal APIs
  • Dapr microservices
  • Event-driven architectures

Explore: azure.github.io/awesome-azd

Over the past week, you’ve learned:

βœ… Day 1: Microsoft Foundry platform βœ… Day 2: Enterprise retail AI scenario βœ… Day 3: App development lifecycle (apartment analogy) βœ… Day 4: AI application architecture patterns βœ… Day 5: Manual provisioning (one chair) βœ… Day 6: ARM/Bicep templates (full kitchen) βœ… Day 7: AZD templates (move-in coordinator)

Key Takeaway: AZD templates provide the most complete, efficient way to deploy AI applications on Azure.

Week 2: AZD Deep Dive - We’ll explore:

  • Installing and configuring AZD
  • Finding the right template
  • Creating custom templates
  • Deploying and customizing
  • Deconstructing template structure
  • Extending with hooks and plugins

Solidify your understanding:

  1. β€œWhat are the key differences between deploying with β€˜azd up’ versus manually running β€˜azd provision’ and β€˜azd deploy’ separately?”
  2. β€œHow do AZD templates handle environment-specific configuration for development, staging, and production?”
  3. β€œWhat happens under the hood when you run β€˜azd deploy’ for a containerized application?”

Next: Day 8 - AZD Workflow

Congratulations on completing Week 1! Next week we dive deep into mastering Azure Developer CLI.