Deploying to Foundry

When it comes to deploying Microsoft Agent Framework applications, Microsoft Foundry offers a robust platform that simplifies the process. This guide will walk you through one approach to deploying your application.

Understanding Microsoft Agent Framework (MAF)

Before diving into the deployment process, it’s essential to understand what the Microsoft Agent Framework is and how it can benefit your applications. MAF is designed to facilitate the development of intelligent agents that can perform tasks, respond to user queries, and integrate with various services. These agents can be deployed in a cloud environment, allowing for scalability and ease of management. For much more on Microsoft Agent Framework see the table of contents here.

Overview of Foundry

Microsoft Foundry is a cloud-based platform that provides a managed environment for deploying and running applications. It abstracts the complexities of infrastructure management, allowing developers to focus on building and deploying their applications. Foundry supports various deployment models, including containerized applications, making it an ideal choice for deploying MAF applications. In this blog post I’ll show how to use containers for deployment. In an upcoming blog post I’ll show a simpler approach.

Key Steps for Deployment

Deploying a MAF application to Foundry using containers involves several key steps. Each step is crucial for ensuring that your application is packaged correctly, deployed efficiently, and registered with the Foundry Agent Service. Below is a detailed breakdown of the deployment process.

Step 1: Build and Package Your Agent

The first step in deploying your MAF application is to build and package it into a Docker container. This process involves creating a Dockerfile that defines how your application will be built and run within a container.

Creating a Dockerfile

A Dockerfile is a text document that contains all the commands needed to assemble an image. Here’s a simple example of a Dockerfile for a MAF application:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "YourApp.dll"]

In this example:

  • The base image is set to the ASP.NET runtime.
  • The working directory is defined as /app.
  • The application files are copied into the container.
  • The entry point is specified to run the application.

Local Testing

Before deploying your application, it’s crucial to test it locally. This ensures that your application behaves as expected and that all endpoints are functioning correctly. You can use the protocol library to validate the endpoints and ensure that your application is ready for deployment.

Step 2: Push to Azure Container Registry

Once your application is packaged into a Docker container, the next step is to push the container image to Azure Container Registry (ACR). ACR is a managed Docker container registry that allows you to store and manage your container images.

Using Azure Developer CLI

To push your container image to ACR, you can use the Azure Developer CLI (azd). Here’s the command to push your container image:

azd container push your-container-image

This command uploads your image to ACR, making it available for deployment.

Step 3: Register the Agent with Foundry

After pushing your container image to ACR, the next step is to register your agent with the Foundry Agent Service. This step provisions the necessary infrastructure and creates a dedicated identity for your agent.

Creating an Agent Version

To register your agent, you can use the following command:

azd foundry agent create --image your-container-image

This command creates an agent version in Foundry using the image you just pushed. It’s important to ensure that the image is accessible and correctly configured.

Step 4: Poll for Status

Once you have registered your agent, poll for the status until it reaches active. This step ensures that your agent is fully provisioned and ready to handle requests.

Step 5: Invoke Your Agent

After your agent is active, you can start sending requests to its dedicated endpoint. This allows you to interact with your agent and utilize its capabilities.

Example Invocation

Here’s an example of how to invoke your agent using Python:

import requests

response = requests.post("https://your-agent-endpoint", json={"input": "Where is Seattle?"})
print(response.json())

The request sends a JSON payload to the agent, and the response is printed to the console.

Key Considerations

When deploying a MAF application to Foundry, there are several key considerations to keep in mind:

Local Testing

Before deploying, ensure that your agent works locally. The container should serve the same endpoints locally as it does in production. This step will identify any issues before deployment.

Managed Infrastructure

One of the significant advantages of using Foundry is that it provides a managed environment. This means you don’t have to worry about the underlying infrastructure. Each agent gets its own dedicated endpoint and identity, simplifying the deployment process.

Multi-Agent Workflows

Foundry supports orchestrating complex workflows using multiple agents.

Conclusion

Deploying a Microsoft Agent Framework application to Foundry is a structured process that involves building, packaging, and registering your application. By following the steps outlined in this guide, you can ensure that your MAF application is deployed efficiently and effectively, leveraging the capabilities of the Foundry platform.

Additional Resources

For further reading see Deploy a hosted agent – Microsoft Learn

Index of Agentic Articles

Unknown's avatar

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen online courses. Liberty is a Senior AI Engineer at the University of Pittsburgh Medical Center, and was a Team Lead and Senior Software Engineer for various corporations, a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a 21 year Microsoft MVP.
This entry was posted in AI. Bookmark the permalink.