Skip to main content
This tutorial covers the first stage of the Microsoft Foundry developer journey: from an initial idea to a working prototype. You build a modern workplace assistant that combines internal company knowledge with external technical guidance by using the Microsoft Foundry SDK. Business scenario: Create an AI assistant that helps employees by combining:
  • Company policies (from SharePoint documents)
  • Technical implementation guidance (from Microsoft Learn via MCP)
  • Complete solutions (combining both sources for business implementation)
  • Batch evaluation to validate agent performance on realistic business scenarios
Tutorial outcome: By the end you have a running Modern Workplace Assistant that can answer policy, technical, and combined implementation questions; a repeatable batch evaluation script; and clear extension points (other tools, multi‑agent patterns, richer evaluation). You will:
  • Build a Modern Workplace Assistant with SharePoint and MCP integration.
  • Demonstrate real business scenarios combining internal and external knowledge.
  • Implement robust error handling and graceful degradation.
  • Create evaluation framework for business-focused testing.
  • Prepare foundation for governance and production deployment. This minimal sample demonstrates enterprise-ready patterns with realistic business scenarios.
Code in this article uses packages that are currently in preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Prerequisites

  • An Azure subscription. If you don’t have one, create one for free.
  • Azure CLI 2.67.0 or later, authenticated with az login (check with az version)
  • A Foundry project with a deployed model (for example, gpt-4o-mini). If you don’t have one: Create a project and then deploy a model (see model overview: Model catalog).
  • Python 3.10 or later
  • .NET SDK 8.0 or later (for the C# sample)
  • SharePoint connection configured in your project (SharePoint tool documentation)
To configure your Foundry project for SharePoint connectivity, see the SharePoint tool documentation.
  • (Optional) Git installed for cloning the sample repository
SDK versions and sample repository structure may change after publication. Before you begin, check the sample repository README for the latest setup instructions, required package versions, and environment configuration. If a version referenced in this tutorial isn’t available on PyPI or NuGet, use the latest published version instead.

Step 1: Get the sample code

Instead of navigating a large repository tree, use one of these approaches:

Option A (clone entire samples repo)

Code uses Azure AI Projects 2.x and is incompatible with Azure AI Projects 1.x. See the Foundry (classic) documentation for the Azure AI Projects 1.x version.

Option B (sparse checkout only this tutorial - reduced download)

Option C (Download ZIP of repository)

Download the repository ZIP, extract it to your local environment, and go to the tutorial folder.
For production adoption, use a standalone repository. This tutorial uses the shared samples repo. Sparse checkout minimizes local noise.

Download the Python code now

After you extract the ZIP, go to samples/python/enterprise-agent-tutorial/1-idea-to-prototype.
The minimal structure contains only essential files:

Step 2: Run the sample immediately

Start by running the agent so you see working functionality before diving into implementation details.

Environment setup and virtual environment

  1. Install the required language runtimes, global tools, and VS Code extensions as described in Prepare your development environment.
  2. Verify that your requirements.txt uses these published package versions:
  3. Install dependencies:

    Python

    C#


    Verify the install succeeded. You should see Successfully installed azure-ai-projects-... (Python) or Restore completed (.NET) with no errors.
  4. Find your project endpoint on the welcome screen of the project.
Screenshot of Microsoft Foundry Models welcome screen showing the endpoint URL and copy button.
  1. Configure .env. Set the environment values required for your language.
Copy .env.template to .env.
Confirm .env contains valid values by opening the file and verifying that FOUNDRY_PROJECT_ENDPOINT starts with https:// and FOUNDRY_MODEL_NAME matches the name of a deployed model in your project.
To get your tenant ID, run:
To get your project endpoint, open your project in the Foundry portal and copy the value shown there.

Run agent and evaluation

Expected output (agent first run)

Successful run with SharePoint:
Graceful degradation without SharePoint:
Now that you have a working agent, the next sections explain how it works. You don’t need to take any action while reading these sections—they’re for explanation.

Step 3: Set up sample SharePoint business documents

  1. Go to your SharePoint site (configured in the connection).
  2. Create document library “Company Policies” (or use existing “Documents”).
  3. Upload the four sample Word documents provided in the sharepoint-sample-data folder:
    • remote-work-policy.docx
    • security-guidelines.docx
    • collaboration-standards.docx
    • data-governance-policy.docx
  4. Verify that four documents appear in the library before proceeding.

Sample structure

Understand the assistant implementation

This section is for reference only — no action needed. It explains the code you already ran.
This section explains the core code in main.py (Python) or ModernWorkplaceAssistant/Program.cs (C#). You already ran the agent. After reading it, you can:
  • Add new internal and external data tools.
  • Extend dynamic instructions.
  • Introduce multi-agent orchestration.
  • Enhance observability and diagnostics.
The code breaks down into the following main sections, ordered as they appear in the full sample code:
  1. Configure imports and authentication
  2. Configure authentication to Azure
  3. Configure the SharePoint tool
  4. Configure MCP tool
  5. Create the agent and connect the tools
  6. Converse with the agent
Code in this article uses packages that are currently in preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Imports and authentication setup

The code uses several client libraries from the Microsoft Foundry SDK to create a robust enterprise agent.

Configure authentication in Azure

Before you create your agent, set up authentication to the Foundry.

Create the SharePoint tool for the agent

The agent uses SharePoint and can access company policy and procedure documents stored there. Set up the connection to SharePoint in your code.

Create the MCP tool for the agent

Create the agent and connect the tools

Create the agent and connect the SharePoint and MCP tools.

Converse with the agent

Finally, implement an interactive loop to converse with the agent.

Expected output from agent sample code

When you run the agent, you see output similar to the following example. The output shows successful tool configuration and agent responses to business scenarios:

Step 4: Evaluate the assistant by using batch evaluation

The evaluation framework tests realistic business scenarios by using the batch evaluation capability of the Microsoft Foundry SDK. Instead of a custom local approach, this pattern uses the built-in evaluators (builtin.violence, builtin.fluency, builtin.task_adherence) and the openai_client.evals API to run scalable, repeatable evaluations in the cloud. This evaluation framework demonstrates:
  • Agent targeting: The evaluation runs queries directly against your agent by using azure_ai_target_completions.
  • Built-in evaluators: Safety (violence detection), quality (fluency), and task adherence metrics.
  • Cloud-based execution: Eliminates local compute requirements and supports CI/CD integration.
  • Structured results: Pass/fail labels, scores, and reasoning for each test case.
The code breaks down into the following main sections:
  1. Configure the evaluation.
  2. Run the batch evaluation.
  3. Retrieve evaluation results.
For detailed guidance on batch evaluations, see Run evaluations in the cloud. To find a comprehensive list of built-in evaluators available in Foundry, see Observability in generative AI.
The C# sample uses a local batch evaluation approach with ProjectResponsesClient instead of the cloud openai_client.evals API shown in Python. It sends queries to the agent, checks responses against expected keywords, and writes results to evaluation_results.json. See the C# Evaluations SDK sample for cloud evaluation patterns in C#.

Configure the evaluation

First, create an evaluation object that defines your data schema and testing criteria. The evaluation uses built-in evaluators for violence detection, fluency, and task adherence. In Python, use the OpenAI client directly. In C#, get an EvaluationClient from the project client:
The testing_criteria array specifies which evaluators to run:
  • builtin.violence: Detects violent or harmful content in responses.
  • builtin.fluency: Assesses response quality and readability (requires a model deployment).
  • builtin.task_adherence: Evaluates whether the agent followed instructions correctly.

Run the batch evaluation

Create an evaluation run that targets your agent. The azure_ai_target_completions data source sends queries to your agent and captures responses for evaluation:
The data_source configuration:
  • type: azure_ai_target_completions routes queries through your agent
  • source: Inline content with test queries (you can also use a dataset file ID)
  • input_messages: Template that formats each query for the agent
  • target: Specifies the agent name and version to evaluate

Retrieve evaluation results

Poll the evaluation run until it completes, then retrieve the detailed output items:
Each output item includes:
  • Label: Binary “pass” or “fail” result
  • Score: Numeric score on the evaluator’s scale
  • Reason: Explanation of why the score was assigned (for LLM-based evaluators)

Expected output from batch evaluation (evaluate.py)

When you run the evaluation script, you see output similar to the following example. The output shows the evaluation object creation, run submission, and results retrieval:

Understanding evaluation results

Batch evaluations provide structured results that you can view in the Foundry portal or retrieve programmatically. Each output item includes: Score scales by evaluator type:
  • Quality evaluators (fluency, coherence): 1-5 scale
  • Safety evaluators (violence, self-harm): 0-7 severity scale (lower is safer)
  • Task evaluators (task_adherence): 1-5 scale
You can also view detailed results in the Foundry portal by selecting Evaluation from your project and selecting the evaluation run. The portal provides visualizations, filtering, and export options.
For production scenarios, consider running evaluations as part of your CI/CD pipeline. See How to run an evaluation in Azure DevOps, and Continuously evaluate your AI agents for integration patterns.

Troubleshooting

Summary

You now have:
  • A working single-agent prototype grounded in internal and external knowledge.
  • A repeatable evaluation script demonstrating enterprise validation patterns.
  • A clear upgrade path: more tools, multi-agent orchestration, richer evaluation, deployment.
These patterns reduce prototype-to-production friction: you can add data sources, enforce governance, and integrate monitoring without rewriting core logic.

Next steps

This tutorial demonstrates Stage 1 of the developer journey - from idea to prototype. This minimal sample provides the foundation for enterprise AI development. To continue your journey, explore the next stages:

Suggested additional enhancements

Stage 2: Prototype to production

Stage 3: Production to adoption

Clean up resources

When you no longer need them, delete the resources you created in this tutorial:
  1. Delete the agent: The agent is automatically deleted at the end of main.py (Python) or Program.cs (C#). If you interrupted the run, delete it manually from the Agents page in the Foundry portal.
  2. Delete the evaluation run: In the Foundry portal, go to Evaluation, select the evaluation run, and delete it.
  3. Remove SharePoint sample documents: If you uploaded the sample .docx files to a production SharePoint site, remove them from the document library.
  4. (Optional) Delete the Foundry project: If you created a project only for this tutorial, delete it from the Foundry portal to remove all associated resources.