Skip to content

arnaud-tincelin/MicrosoftFoundryHostedAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Foundry Hosted Agent Demo

This repository demonstrates how to deploy a Hosted Agent on Microsoft Foundry using the Azure Developer CLI (azd) AI Agent extension.

More information on my blog.

Prerequisites

  • Azure Developer CLI (azd) (version 1.21.3 or later)
  • Azure CLI
  • Azure AI Agent extension for azd (installed automatically on first run, or manually via azd extension install azure.ai.agents)

Quick Start with Dev Container

This repository includes a dev container configuration. To use it:

  1. Open this repository in VS Code
  2. When prompted, click "Reopen in Container" (or use Dev Containers: Reopen in Container from the command palette)
  3. The container will automatically install all required tools (Azure CLI, azd, Docker)

Usage

Deploy the agent

az login
azd auth login
azd up

The azd up command orchestrates the complete deployment workflow:

  1. Provisions the Azure infrastructure (Microsoft Foundry account, project, Container Registry)
  2. Builds the container image and pushes it to Azure Container Registry
  3. Deploys the agent to Microsoft Foundry
  4. Starts the hosted agent container

When complete, the output displays:

  • Microsoft Foundry project endpoint
  • Agent name and version
  • Direct link to the agent playground in the Microsoft Foundry portal

Other useful commands

# Only provision infrastructure
azd provision

# Only deploy the agent (after code changes)
azd deploy

# View deployment outputs
azd env get-values

# Delete all resources
azd down

Access the agent playground

Use the link provided at the end of the deployment (🌐 View in portal) to access the playground and chat with your agent:

foundry.png

Project Structure

├── agent/
│   ├── agent.yaml          # Agent definition and metadata
│   ├── Dockerfile          # Container image definition
│   ├── hostedAgent.py      # Agent implementation using Microsoft Agent Framework
│   └── pyproject.toml      # Python dependencies
├── infra/
│   ├── main.bicep          # Azure infrastructure as code
│   └── main.parameters.json
└── azure.yaml              # Azure Developer CLI configuration

How it works

This project uses a declarative approach with the Azure Developer CLI AI Agent extension:

  1. Agent Definition (agent/agent.yaml): Defines the agent's metadata, instructions, and container configuration
  2. Service Configuration (azure.yaml): Declares the agent as a service with container resources, scaling, and environment variables
  3. Infrastructure (infra/main.bicep): Provisions Microsoft Foundry account, project, Container Registry, and RBAC permissions
  4. Automatic Deployment: azd up handles the entire lifecycle from infrastructure to running agent

The agent uses:

  • Ollama running locally in the container with the Llama 3.2 3B model
  • Microsoft Agent Framework for agent runtime capabilities
  • Azure Container Registry for image storage
  • Microsoft Foundry Hosted Agents for scalable, managed hosting

Multiple Environments

azd supports multiple named environments for different deployment stages:

# Create a new environment (e.g., production)
azd env new my-agent-prod

# Switch between environments
azd env select my-agent-dev
azd env select my-agent-prod

# Deploy to the selected environment
azd up

Learn More

About

Microsoft Foundry Hosted Agent Demo repository

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors