Files
agent-framework/python/samples/04-hosting/foundry-hosted-agents
T
Eduard van Valkenburg 62e02da698 Python: update FoundryAgent for hosted agent sessions (#5447)
* fixes to FoundryAgent to connect to new hosted agents

Co-authored-by: Copilot <copilot@github.com>

* fix mypy

Co-authored-by: Copilot <copilot@github.com>

* Python: remove Foundry service session helpers

Remove the public hosted-agent service session CRUD helpers from FoundryAgent and drop the related feature-stage inventory entry.

Update the hosted-agent sample to create and delete service sessions directly through the preview AIProjectClient APIs, and tighten a few test harnesses surfaced by full workspace validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix from merge

* fix hosted env detection

Co-authored-by: Copilot <copilot@github.com>

* reverted sample update

* fix tests and code

Co-authored-by: Copilot <copilot@github.com>

* remove aenter

* skipping some tests

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
62e02da698 ยท 2026-04-24 09:25:03 +00:00
History
..

Foundry Hosted Agents Samples

This directory contains samples that demonstrate how to use the Agent Framework to host agents on Foundry with different capabilities and configurations. Each sample includes a README with instructions on how to set up, run, and interact with the agent.

Read more about Foundry Hosted Agents here.

Environment setup

  1. Navigate to the sample directory you want to run. For example:

    python -m venv .venv
    
    # Windows
    .venv\Scripts\Activate
    
    # macOS/Linux
    source .venv/bin/activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Create a .env file with your Foundry configuration following the env.example file in the sample.

  4. Make sure you are logged in with the Azure CLI:

    az login
    

Deploying to a Docker container

Navigate to the sample directory and build the Docker image:

docker build -t hosted-agent-sample .

Run the container, passing in the required environment variables:

docker run -p 8088:8088 \
  -e FOUNDRY_PROJECT_ENDPOINT=<your-endpoint> \
  -e MODEL_DEPLOYMENT_NAME=<your-model> \
  hosted-agent-sample

The server will be available at http://localhost:8088. You can send requests using the same curl command shown above.

Deploying to Foundry

Follow this guide to deploy your agent to Foundry.