# Your first agent. In code.

> The portal cannot edit function tools.

- **Format:** short video, 9 steps, ~51 seconds
- **Topic:** Microsoft Foundry project setup: resource, project endpoint, model deployment, the Foundry User role, and why the agent is created in C# rather than the portal.
- **Author:** Suthahar Jegatheesan (MSDEVBUILD)
- **Category:** Azure · Azure
- **Published:** 2026-05-06
- **Tags:** microsoftfoundry, azureai, aiagents, dotnet, flutter, azure, aicoding, msdevbuild
- **Canonical URL:** https://blog.msdevbuild.com/shorts/foundry-first-agent-in-code/

---
## What you'll learn

- The setup steps in order
- Why RBAC comes before code
- Why the agent belongs in source control

## Understand it one step at a time

### 1. Three empty strings

ProjectEndpoint, ModelDeployment, AgentName.

### 2. Resource and project

Create the Foundry resource, then the project, and copy its endpoint.

### 3. Deploy a model

The deployment name is what your code refers to.

### 4. Foundry User first

Without the role assignment, every call is a 403.

### 5. Prove it before C#

One az call that succeeds before you write a line of C#.

### 6. Portal or code?

The portal cannot add, remove or update function tool definitions.

### 7. The agent in C#

DeclarativeAgentDefinition, instructions from a file under source control.

### 8. It refuses to guess

Asked a price with no tool, it declines instead of inventing one.

### 9. Create the agent in code

The portal cannot edit function tools. Code can, and it gets reviewed.

---

## The takeaway

**Create the agent in code.**

Resource, project, model, role, then the agent in C# with its instructions in source control.
