In a sequential pattern, agents work one after another in a defined pipeline, where each agent's output feeds into the next. This approach works well for tasks that follow a natural progression, like content creation workflows, staged data transformations, or step-by-step analysis.
You're writing a technical blog post with agents – research agent, outliner agent, writer agent, and editor agent.
-
Get the
$REPOSITORY_ROOTvariable first.# zsh/bash REPOSITORY_ROOT=$(git rev-parse --show-toplevel)
# PowerShell $REPOSITORY_ROOT = git rev-parse --show-toplevel
-
If you already have the
workshopdirectory, rename or remove it first. -
Run the setup script to copy the start project to the
workshopdirectory.# zsh/bash bash $REPOSITORY_ROOT/scripts/setup.sh --session 01-sequential-pattern
# PowerShell & $REPOSITORY_ROOT/scripts/setup.ps1 -Session 01-sequential-pattern
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Open
src/MultiAgentWorkshop.PromptAgent/appsettings.json, find the comment line// Add agents, and add theAgentsproperty underneath it. -
Navigate to the
resources-foundrydirectory.pushd resources-foundry -
Run the following command to provision and deploy the agents defined above to Microsoft Foundry.
azd up
While provisioning, you'll be asked to enter an environment name, Azure subscription, and location.
-
Once provisioning and deployment are done, run the following command to confirm that the agents have been deployed successfully.
# zsh/bash az cognitiveservices agent list \ -a $(azd env get-value FOUNDRY_NAME) \ -p $(azd env get-value FOUNDRY_PROJECT_NAME) \ --query "[].id" -o tsv
# PowerShell az cognitiveservices agent list ` -a $(azd env get-value FOUNDRY_NAME) ` -p $(azd env get-value FOUNDRY_PROJECT_NAME) ` --query "[].id" -o tsv
You should see the four agent names.
editor-agent writer-agent outliner-agent research-agent -
Navigate back to the workshop directory.
popd
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Verify that all the necessary agent information has been recorded.
dotnet user-secrets --project ./src/MultiAgentWorkshop.AppHost list
You should see the
AZURE_TENANT_ID,FOUNDRY_NAME,FOUNDRY_PROJECT_NAME,FOUNDRY_RESOURCE_GROUP, andFoundry:Project:Endpointvalues. -
Open
src/MultiAgentWorkshop.AppHost/appsettings.json, find the comment line// Add agents, and add theAgentsproperty underneath it.{ ... // Add agents "Agents": [ "research-agent", "outliner-agent", "writer-agent", "editor-agent" ] ... } -
Open
src/MultiAgentWorkshop.AppHost/AppHost.cs, find the comment// Add resource for Microsoft Foundryand add the code right underneath it. This adds the Microsoft Foundry project connection details.// Add resource for Microsoft Foundry var foundry = builder.AddFoundryConnectionString("foundry");
Let's break down the code.
builder.AddFoundryConnectionString("foundry"): This adds the Microsoft Foundry connection string through the extension methodAddFoundryConnectionString().
-
In the same file, find the comment
// Add resource for agents on Microsoft Foundryand add the code right underneath it. This exposes the list of agent details to the referencing application.// Add resource for agents on Microsoft Foundry var agents = builder.AddFoundryAgentsConnectionString("agents");
Let's break down the code.
builder.AddFoundryAgentsConnectionString("agents"): This adds the list of agent details through the extension methodAddFoundryAgentsConnectionString().
-
In the same file, find the comment
// Add backend agent serviceand add the code right underneath it. This defines the backend agent service that references thefoundryresource – all the Microsoft Foundry connection details are passed to the backend agent service app.// Add backend agent service var agent = builder.AddProject<Projects.MultiAgentWorkshop_Agent>("agent") .WithReference(foundry) .WaitFor(foundry);
Let's break down the code.
builder.AddProject<Projects.MultiAgentWorkshop_Agent>("agent"): This adds the backend agent service app as a .NET project..WithReference(foundry): This references the foundry connection string resource created above, which passes the Microsoft Foundry connection details to the backend agent service app..WaitFor(foundry): This keeps dependency activation order so that thisagentproject resource won't be activated until thefoundryconnection resource is up and running.
-
In the same file, find the comment
// Add frontend web UIand add the code right underneath it. This defines the frontend web UI that references both theagentsandagentresources – the agent details and backend connection details are both passed to the frontend web UI app.// Add frontend web UI var webUI = builder.AddProject<Projects.MultiAgentWorkshop_WebUI>("webui") .WithExternalHttpEndpoints() .WithReference(agents) .WithReference(agent) .WaitFor(agents) .WaitFor(agent);
Let's break down the code.
builder.AddProject<Projects.MultiAgentWorkshop_WebUI>("webui"): This adds the frontend web UI app as a .NET project..WithExternalHttpEndpoints(): This exposes this frontend web UI app to the Internet, which is publicly accessible..WithReference(agents): This references the agents connection string resource created above, which passes the list of agents to the frontend web UI app..WithReference(agent): This references the backend agent service app, which passes the connection details to the frontend web UI app..WaitFor(agents): This keeps dependency activation order so that thiswebuiproject resource won't be activated until theagentsconnection resource is up and running..WaitFor(agent): This keeps dependency activation order so that thiswebuiproject resource won't be activated until theagentproject resource is up and running.
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Open
src/MultiAgentWorkshop.Agent/Program.cs, find the comment// Create AIProjectClient instance with EntraID authenticationand add the code right underneath it. This connects to the Microsoft Foundry project.// Create AIProjectClient instance with EntraID authentication var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions() { TenantId = config["AZURE_TENANT_ID"] }); var projectClient = new AIProjectClient(endpoint: new Uri(endpoint!), tokenProvider: credential);
Let's break down the code.
new DefaultAzureCredential(...): This logs in to Azure without an API key. It uses your Azure CLI login or Azure Developer CLI login details on your local machine, and Managed Identity when the app is deployed to Azure.new AIProjectClient(endpoint, credential): This connects to the Microsoft Foundry project instance using the endpoint and login details.
-
In the same file, find the comment
// Register all agents passed from Aspireand add the code right underneath it. This pulls the agent details from the Microsoft Foundry project and registers them in the IoC container as singleton services.// Register all agents passed from Aspire foreach (var agentName in agentNames!) { var agentRecord = await projectClient.AgentAdministrationClient .GetAgentAsync(agentName); var agent = projectClient.AsAIAgent(agentRecord); builder.Services.AddKeyedSingleton<AIAgent>(agentName, agent); }
Let's break down the code.
- We already know the list of agents but only know their names. Therefore, the code runs the
foreachloop for each agent. projectClient.AgentAdministrationClient.GetAgentAsync(agentName): Using each agent's information, this creates anProjectsAgentRecordinstance.projectClient.AsAIAgent(agentRecord): This connects to the actual agent using the reference details.builder.Services.AddKeyedSingleton<AIAgent>(agentName, agent): This registers the agent instance as a singleton service.
- We already know the list of agents but only know their names. Therefore, the code runs the
-
In the same file, find the comment
// Build a sequential workflow pattern with the agents registeredand add the code right underneath it.// Build a sequential workflow pattern with the agents registered builder.AddWorkflow("publisher", (sp, key) => AgentWorkflowBuilder.BuildSequential( workflowName: key, agents: [.. agentNames!.Select(name => sp.GetRequiredKeyedService<AIAgent>(name))] )).AddAsAIAgent("publisher");
Let's break down the code.
-
builder.AddWorkflow("publisher", ...).AddAsAIAgent("publisher"): This adds the multi-agent workflow as another agent instance namedpublisherand registers it as a singleton. -
AgentWorkflowBuilder.BuildSequential(...): This is the sequential workflow builder that uses the same name,publisher.Note that it adds multiple agents from the previously registered services in the order declared by the
agentNamesarray.
-
-
In the same file, find the comment
// Map AGUI to the publisher workflow agentand add the code right underneath it. The workflow is exposed as an API endpoint atag-uiso that the frontend web UI can communicate with this backend agent service app.// Map AGUI to the publisher workflow agent app.MapAGUI( pattern: "ag-ui", aiAgent: app.Services.GetRequiredKeyedService<AIAgent>("publisher") );
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Open
src/MultiAgentWorkshop.WebUI/Program.cs, find the comment// Register all agents passed from Aspireand add the code right underneath it. This registers all the agent details so that the web UI knows which agent is responding.// Register all agents passed from Aspire builder.Services.AddSingleton(agentNames!);
-
In the same file, find the comment
// Register the backend agent service as an HTTP clientand add the code right underneath it. Aspire already provides the frontend web UI app with the connection details for the backend agent service.// Register the backend agent service as an HTTP client builder.Services.AddHttpClient("agent", client => { client.BaseAddress = new Uri("https+http://agent"); });
-
In the same file, find the comment
// Register AGUI clientand add the code right underneath it. Using this AGUI client, the frontend web UI app communicates with the backend agent service app via theag-uiendpoint.// Register AGUI client builder.Services.AddChatClient(sp => new AGUIChatClient( httpClient: sp.GetRequiredService<IHttpClientFactory>().CreateClient("agent"), endpoint: "ag-ui") );
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Make sure you've already logged in to Azure using both Azure CLI and Azure Developer CLI. If you're unsure, follow this step again.
-
Run the following command to start all apps through Aspire.
dotnet watch run --project ./src/MultiAgentWorkshop.AppHost
-
The Aspire dashboard opens automatically.
Click the backend agent service app.
-
When the Dev UI page opens, change the agent to
publisherand click the "Configure & Run" button. -
Send any request.
See the result and how the workflow progresses on the left-hand side of the screen.
-
Go back to the Aspire dashboard and click the web UI app.
-
Send any request.
See the result.
-
Press
Ctrl+Cto terminate all running apps.
-
Make sure you're in the
workshopdirectory.cd $REPOSITORY_ROOT/workshop
-
Run the following command to provision and deploy both the frontend web UI and backend agent service apps to Azure.
azd up
While provisioning, you'll be asked to enter an environment name, Azure subscription, and location.
-
Once completed, you'll see the web UI application URL on the terminal screen. Open it in your web browser and send a request.
See the result.
-
Once everything is done, remove all the apps and agents from Azure.
# Delete both the web UI and agent service apps. azd down --purge --force # Delete all agents and the Microsoft Foundry resource. cd resources-foundry azd down --purge --force
Congratulations! 🎉 You've just completed the first multi-agent orchestration scenario - the sequential pattern. Let's move on!








{ ... // Add agents "Agents": [ "research-agent", "outliner-agent", "writer-agent", "editor-agent" ] ... }