Skip to content

JayRHa/foundry-book-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Foundry — the code

Every listing from the book Microsoft Foundry by Jannik Reinhard, as a file you can run, plus a handful of extra examples that came out of writing it.

Start here

git clone https://github.com/JayRHa/foundry-book-code
cd foundry-book-code

az login
export PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"
export FOUNDRY_OPENAI_BASE_URL="https://<resource>.openai.azure.com/openai/v1/"

pip install -r requirements.txt
python ch08-first-agent/create_agent.py

Both endpoints are on the project's overview page in the Foundry portal. Nothing here uses an API key — see Chapter 13 for why.

Chapters

Chapter What is in it
3 Your First Foundry Resource The resource and project, in CLI and Bicep
4 The Model Catalog What you can really deploy, in this region, today
5 Deploying Models Deployments, SKUs, and the Batch API
6 Talking to Models in Code Chat, streaming, structured output, vision, Claude
7 Grounding AI in Your Data Connections and knowledge bases
8 Your First Agent Agent, conversation, response — SDK and REST
9 Agent Tools Function calling, OpenAPI, MCP
10 Multi-Agent and Memory A2A, orchestration, hosted agents, memory
11 Fine-Tuning Training data, the job, the deployment
12 Beyond Text Images, video, Foundry Tools
13 Identity and Access RBAC, killing the keys, agent identity
14 Network Security Private endpoints, abuse-monitoring opt-out
15 Guardrails Handling a content-filter block honestly
16 Evaluations and Red Teaming Scoring an agent, attacking an agent
17 The Control Plane Azure Policy over models
18 Agent 365 The agent registry and its policies
19 GenAIOps Bicep, Terraform, CI/CD with an evaluation gate
20 Publishing Agents Versions, updates, rollback
21 Foundry at the Edge Foundry Local
Appendix RBAC table, az cheat sheet, Bicep skeleton

Extra examples

Not in the book. Each one answers a question the docs left open, and each was run against a real project before it landed here.

What it answers
rest-surface-probe/ Why does the same project endpoint want api-version on one path and reject it on another?
streaming-with-citations/ What is in the event stream besides text?
rbac-roles/ What does each Foundry role actually grant?
cost-audit/ What in this resource group is billing me right now?

About the code

These are the book's listings, not a rewrite of them. A listing printed in a book can lean on the prose around it: the book explains what PROJECT_ENDPOINT is a page earlier, so the listing just uses it. A file cannot. So each file here adds the bootstrap the book resolves in prose — reading the endpoint from the environment, constructing the client — and otherwise leaves the code exactly as printed. Where the book shows a fragment on purpose, the file says so in its docstring and shows the surrounding lines it needs.

Where reality has since diverged from what shipped, the file says so rather than pretending. See the note at the top of ch16-evaluations/red_team.py for an example.

Every file starts with a docstring naming its chapter and the exact export lines it needs. There is no shared config module: each file stands alone, so you can copy one out of here and into your own project without dragging anything with it.

Related

License

MIT — see LICENSE.

About

All the code from the book 'Microsoft Foundry' by Jannik Reinhard — every listing as a runnable file, plus extra examples.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors