This scenario demonstrates concurrent agent orchestration using the Microsoft Agent Framework (MAF). The goal is to showcase how multiple agents can work in parallel to analyze user queries and provide valuable insights for future analysis.
Whenever a user performs a search in the store application, two agents are triggered to run concurrently:
-
Sentiment Analysis Agent: Analyzes the sentiment of the user's query.
-
Language Detection Agent: Determines the language of the user's query.
While the standard application continues to answer the user's question as usual, the concurrent execution of these agents stores a set of insights (sentiment and language) for each query. These insights are saved for future analysis and can be reviewed in the application.
- Concurrent Agent Execution: Utilizes the Microsoft Agent Framework to orchestrate multiple agents running in parallel.
- Sentiment and Language Analysis: Each user search is analyzed for sentiment and language.
- Insights Storage: Results from the agents are stored for future review.
- Insights Dashboard: The store application includes a new page to view the runs and results of user insights generated by the agents.
The solution is in the ./src folder, the main solution is eShopLite-Agents-Concurrent.slnx.
Once you've opened the project in Codespaces, or locally, you can deploy it to Azure.
From a Terminal window, open the folder with the clone of this repo and run the following commands.
-
Login to Azure:
azd auth login
-
Provision and deploy all the resources:
azd up
It will prompt you to provide an
azdenvironment name (like "eShopLite-AgentsConcurrent"), select a subscription from your Azure account, and select a location where the necessary models gpt-4.1-mini and ADA-002 are available (like "eastus2"). -
When
azdhas finished deploying, you'll see the list of resources created in Azure and a set of URIs in the command output. -
Visit the store URI, and you should see the eShop Lite app! 🎉
-
This is an example of the command output:
Note: The deploy files are located in the ./src/eShopAppHost/infra/ folder. They are generated by the Aspire AppHost project.
-
Create a new Codespace using the
Codebutton at the top of the repository. -
The Codespace creation process can take a couple of minutes.
-
Once the Codespace is loaded, it should have all the necessary requirements to deploy the solution.
To run the project locally, you'll need to make sure the following tools are installed:
- .NET 10
- Git
- Azure Developer CLI (azd)
- Visual Studio Code or Visual Studio
- If using Visual Studio Code, install the C# Dev Kit
- .NET Aspire workload: Installed with the Visual Studio installer or the .NET CLI workload.
- An OCI compliant container runtime, such as:
- Docker Desktop or Podman.
Follow these steps to run the project, locally or in CodeSpaces:
-
Navigate to the Aspire Host folder project using the command:
cd ./src/eShopAppHost/ -
If you are running the project in Codespaces, you need to run this command:
dotnet dev-certs https --trust
-
By default the AppHost project creates the necessary resources on Azure. Check the .NET Aspire Azure Resources creation section to learn how to configure the project to create Azure resources.
-
Run the project:
dotnet run
-
Perform a search in the store application.
-
Visit the new insights page to view the sentiment and language analysis results for each user query.
Note: Working with .NET Aspire in GitHub Codespaces requires manual steps to access the .NET Aspire portal, such as changing ports to public and copying the access token.
When utilizing Azure resources in your local development environment, you need to:
-
Authenticate to the Azure Tenant where the resources will be created. Run the following command to connect with your Azure tenant:
az login
-
Provide the necessary Configuration values are specified under the Azure section in the
eShopAppHostproject:- CredentialSource: Delegates to the AzureCliCredential.
- SubscriptionId: The Azure subscription ID.
- AllowResourceGroupCreation: A boolean value that indicates whether to create a new resource group.
- ResourceGroup: The name of the resource group to use.
- Location: The Azure region to use.
Consider the following example for the appsettings.json file in the eShopAppHost project configuration:
{
"Azure": {
"CredentialSource": "AzureCli",
"SubscriptionId": "<Your subscription id>",
"AllowResourceGroupCreation": true,
"ResourceGroup": "<Valid resource group name>",
"Location": "<Valid Azure location>"
}
}Check .NET Aspire Azure hosting integrations for more information on how .NET Aspire create the necessary cloud resources for local development.
In order to use existing models: gpt-4.1-mini and text-embedding-ada-002, set the Azure OpenAI parameters as user secrets in the eShopAppHost project.
Run these commands from the repo root:
aspire secret set Parameters:AzureOpenAIEndpoint "https://<your-resource>.openai.azure.com/" --apphost scenarios/07-AgentsConcurrent/src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIApiKey "<your-api-key>" --apphost scenarios/07-AgentsConcurrent/src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIDeploymentName "gpt-4.1-mini" --apphost scenarios/07-AgentsConcurrent/src/eShopAppHost/eShopAppHost.csproj
aspire secret set Parameters:AzureOpenAIEmbeddingsDeploymentName "text-embedding-ada-002" --apphost scenarios/07-AgentsConcurrent/src/eShopAppHost/eShopAppHost.csprojTip: Run
pwsh .\scripts\Set-AzureOpenAISecrets.ps1from the repo root to set the 4 common Azure OpenAI values for every scenario at once.
This Azure OpenAI service must contain:
- a
gpt-4.1-minimodel named gpt-41-mini - a
text-embedding-ada-002model named text-embedding-ada-002
The eShopLite solution leverages the Aspire Dashboard and Azure Application Insights to provide comprehensive telemetry and monitoring capabilities
The .NET Aspire Dashboard offers a centralized view of the application's performance, health, and usage metrics. It integrates seamlessly with the Azure OpenAI services, allowing developers to monitor the performance of the gpt-4.1-mini and text-embedding-ada-002 models. The dashboard provides real-time insights into the application's behavior, helping to identify and resolve issues quickly.
Azure Application Insights complements the Aspire Dashboard by offering deep diagnostic capabilities and advanced analytics. It collects detailed telemetry data, including request rates, response times, and failure rates, enabling developers to understand how the application is performing under different conditions. Application Insights also provides powerful querying and visualization tools, making it easier to analyze trends and detect anomalies.
By combining the Aspire Dashboard with Azure Application Insights, the eShopLite solution ensures robust monitoring and diagnostics, enhancing the overall reliability and performance of the application.
WIP - Coming soon!
For Azure OpenAI Services, pricing varies per region and usage, so it isn't possible to predict exact costs for your usage. The majority of the Azure resources used in this infrastructure are on usage-based pricing tiers. However, Azure Container Registry has a fixed cost per registry per day.
You can try the Azure pricing calculator for the resources:
- Azure OpenAI Service: S0 tier, gpt-4.1-mini and text-embedding-ada-002 models. Pricing is based on token count. Pricing
- Azure Container App: Consumption tier with 0.5 CPU, 1GiB memory/storage. Pricing is based on resource allocation, and each month allows for a certain amount of free usage. Pricing
- Azure Container Registry: Basic tier. Pricing
- Log analytics: Pay-as-you-go tier. Costs based on data ingested. Pricing
- Azure Application Insights pricing is based on a Pay-As-You-Go model. Pricing.
azd down.
Samples in this templates uses Azure OpenAI Services with ApiKey and Managed Identity for authenticating to the Azure OpenAI service.
The Main Sample uses Managed Identity](https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview) for authenticating to the Azure OpenAI service.
Additionally, we have added a GitHub Action that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure continued best practices in your own repository, we recommend that anyone creating solutions based on our templates ensure that the Github secret scanning setting is enabled.
You may want to consider additional security measures, such as:
- Protecting the Azure Container Apps instance with a firewall and/or Virtual Network.
- Microsoft Agent Framework (MAF)
- Microsoft.Extensions.AI Documentation
- eShopLite Main Repository
- Deploy a .NET Aspire project to Azure Container Apps using the Azure Developer CLI (in-depth guide)
- Aspiring .NET Applications with Azure OpenAI
This scenario is part of the eShopLite sample, demonstrating advanced AI orchestration patterns for .NET developers.
