Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ This agent uses the **Activity protocol** (Bot Framework / M365 Agents SDK), so
## Key files

- `main.py` — the activity handlers (`message` echoes the user's text; `conversationUpdate` welcomes new members)
- `pyproject.toml` — direct runtime dependencies and Python compatibility
- `uv.lock` — reproducible dependency graph used by local and container workflows
- `Dockerfile` — container definition

## Development workflow

The **Azure Developer CLI (`azd`)** manages the full lifecycle:

```bash
cd src/echo-activity
uv sync --frozen
cd ../..
azd ai agent run
azd deploy # Deploy to Foundry (creates the Azure Bot + Teams channel)
```
Expand All @@ -27,6 +32,8 @@ POST a synthetic activity to `http://localhost:8088/activity/messages` with a

## Microsoft Foundry Skill

This project was built with the microsoft-foundry skill. Before working on or answering questions about foundry agents, read the microsoft-foundry skill first.
Comment thread
Copilot marked this conversation as resolved.
Outdated

Install the **Microsoft Foundry Skill** for guided deployment, evaluation, and troubleshooting workflows.

Direct install (preferred, works with any coding agent):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Make sure the following are installed and available:
|-------------|-----------------|
| [Azure Developer CLI (`azd`)](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd) | Provisions infrastructure and deploys the agent. Use **1.25 or later** (earlier versions have a container-registry resolution bug during remote build). Install the agent service target with `azd extension install azure.ai.agents`. |
| [Azure CLI (`az`)](https://learn.microsoft.com/cli/azure/install-azure-cli) | Authentication (`az login`). |
| [Python 3.10+](https://www.python.org/downloads/) | The agent runtime (built inside the Docker image; also handy for local edits). |
| [Python 3.13+](https://www.python.org/downloads/) | Matches the local, container, and hosted runtime declared by the sample. |
| [uv 0.11.7+](https://docs.astral.sh/uv/getting-started/installation/) | Creates the local environment from the committed lockfile. |
| [Docker](https://www.docker.com/products/docker-desktop/) | **Optional.** `azd deploy` uses a remote ACR build, so you don't need Docker unless you want to build the image locally. |

### Required permissions
Expand Down Expand Up @@ -80,14 +81,25 @@ If you opened the repo root folder, add the inner folder first:

The Explorer panel should now show `echo-activity` as a workspace root (with its own `.vscode/` visible). You can then save this as a multi-root workspace file if you like.

### Step 2: Press F5
### Step 2: Prepare the locked Python environment

From the sample directory:

```powershell
Set-Location src/echo-activity
uv sync --frozen
Set-Location ../..
```

In VS Code, select the Python interpreter from `src/echo-activity/.venv`.

### Step 3: Press F5

Press **F5** (or **Run → Start Debugging**). The launch configuration will:

1. Install `agentsplayground` if not already installed (one-time, via winget).
2. Create a `.venv` (Python 3.13) and install `requirements.txt` if not already done.
3. Start the agent (`main.py`) under the VS Code debugger.
4. Launch **M365 Agents Playground** automatically once port 8088 is ready.
2. Start the agent (`main.py`) under the VS Code debugger using the uv environment.
3. Launch **M365 Agents Playground** automatically once port 8088 is ready.

When the debug session ends, the `postDebugTask` kills `agentsplayground` and any process still bound to port 8088.

Expand Down Expand Up @@ -144,4 +156,3 @@ A single deploy wires together several pieces to produce a working Teams agent:
3. **Agent version + blueprint + instance identity** *(`azd deploy`).* Creating the agent version makes the Foundry service auto-create the Managed Agent Identity Blueprint (MAIB) and provision the agent **instance** identity used for outbound auth — then `azd` patches the `activity` protocol onto the agent endpoint.

4. **Azure Bot + Teams channel** *(foundry extension postdeploy).* An instance-identity bot (`<agent-name>-bot-uai`) whose `msaAppId` is the agent **instance** identity, configured with the agent endpoint and the Microsoft Teams channel.

Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM ghcr.io/astral-sh/uv:0.11.7 AS uv
FROM python:3.13-slim

WORKDIR /app
COPY . user_agent/
COPY --from=uv /uv /uvx /bin/

WORKDIR /app/user_agent
RUN if [ -f requirements.txt ]; then pip install --no-input -r requirements.txt; fi
COPY pyproject.toml uv.lock uv.toml ./
RUN uv sync --frozen --no-dev --no-install-project

COPY . .

EXPOSE 8088

ENV PORT=8088
Expand All @@ -20,7 +25,7 @@ ENV PYTHONUNBUFFERED=1
# container start.
# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks
# bytecode *writes*, not *reads*, so images that set it still benefit.
RUN PYTHONDONTWRITEBYTECODE= python -m compileall -q $(python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \
PYTHONDONTWRITEBYTECODE= python -m compileall -q .
RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \
PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' .

CMD ["python", "main.py"]
CMD ["/app/user_agent/.venv/bin/python", "main.py"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "echo-activity"
version = "0.1.0"
description = "A Microsoft Foundry hosted agent using the Activity protocol."
requires-python = ">=3.13"
dependencies = [
# The M365 SDK connector imports aiohttp but does not declare it.
"aiohttp>=3.9.0",
# Keep the protocol host on the published beta until explicitly upgraded.
"azure-ai-agentserver-activity==1.0.0b1",
"azure-identity>=1.17.0",
"debugpy",
"microsoft-agents-activity",
"microsoft-agents-authentication-msal",
"microsoft-agents-hosting-core",
"python-dotenv>=1.0.0",
]

This file was deleted.

Loading
Loading