This project is an alternative to the python version at https://github.com/Azure-Samples/contoso-creative-writer.
It is a comprehensive example of a chat application built with .NET Aspire, Semantic Kernel, and the @microsoft/ai-chat-protocol
package.
The frontend of the application is developed using React and Vite.
- Features
- Getting Started
- Local Development
- Azure Deployment
- Sample Product Data
- Guidance
- Resources
- Credits
- Important Security Notice
- License
The application consists of 2 main projects:
-
ChatApp.WebApi
: This is a .NET Web API that handles chat interactions, powered by .NET Aspire and Semantic Kernel. It provides endpoints for the chat frontend to communicate with the chat backend. The@microsoft/ai-chat-protocol
package is used to handle chat interactions, including streaming and non-streaming requests. For normal chat completion both can be used, to trigger the creative writer only streaming is possible. -
ChatApp.React
: This is a React app that provides the user interface for the chat application. It is built using Vite, a modern and efficient build tool. It uses the@microsoft/ai-chat-protocol
package to handle chat interactions, allowing for flexible communication with the chat backend.
The app also includes a class library project, ChatApp.ServiceDefaults, that contains the service defaults used by the service projects.
In addition it has two .NET Interactive Notebooks inside the ./experiments/
to show a simple WriterReviewer scenario and also the full version of the CreativeWritingAssistant outside of a real system.
The first step for getting started with this template are the notebooks which can be used as local experiments.
- .NET 9 SDK
- VSCode
- Azure Developer CLI (azd)
Open the notebooks under ./experiments/
and follow their instructions.
- .NET 9 SDK
- VSCode or Visual Studio 2022 17.12
- Node.js 22
- Azure CLI (az)
- Azure Developer CLI (azd)
If using Visual Studio, open the solution file ChatApp.sln
and launch/debug the ChatApp.AppHost
project.
If using the .NET CLI, run dotnet run from the ChatApp.AppHost
directory.
For more information on local provisioning of Aspire applications, refer to the Aspire Local Provisioning Guide.
To utilize Azure resources (e.g. OpenAI) in your local development environment, you need to provide the necessary configuration values.
https://learn.microsoft.com/en-us/dotnet/aspire/azure/local-provisioning#configuration
Example to add into a appsettings.Development.json
in the ChatApp.AppHost
directory:
{
"Azure": {
"SubscriptionId": "<Your subscription id>",
"AllowResourceGroupCreation": true,
"ResourceGroup": "<Valid resource group name>",
"Location": "swedencentral",
"CredentialSource": "InteractiveBrowser"
}
}
If you want to use existing Azure resource, but their endpoints below the Azure section:
{
"Azure": {
"SubscriptionId": "<Your subscription id>",
"AllowResourceGroupCreation": true,
"ResourceGroup": "<Valid resource group name>",
"Location": "swedencentral",
"CredentialSource": "InteractiveBrowser"
},
"ConnectionStrings": {
"openAI": "https://<lorem>.openai.azure.com/",
"vectorSearch": "https://<lorem>.search.windows.net"
}
}
Navigate into ./ChatApp.AppHost/
.
-
Sign in to your Azure account. You'll need to login to both the Azure Developer CLI and Azure CLI:
i. First with Azure Developer CLI
azd auth login
ii. Then sign in with Azure CLI
az login --use-device-code
-
Provision the resources and deploy the code:
azd up
This project uses
gpt-4o
which may not be available in all Azure regions. Check for up-to-date region availability and select a region during deployment accordingly.
We recommend using Schweden Central for this project.
To load sample product data into Azure AI Search as vector store, use the notebook inside ./data/
.
This template uses gpt-4o
and text-embedding-3-large
which may not be available in all Azure regions. Check for up-to-date region availability and select a region during deployment accordingly
- we recommend using eastus2 or swedencentral
You can estimate the cost of this project's architecture with Azure's pricing calculator
This template has Managed Identity and Key Vault built in to eliminate the need for developers to manage credentials. Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. Additionally, we have added a GitHub Action tool that scans the infrastructure-as-code files and generates a report containing any detected issues. To ensure best practices in your repo we recommend anyone creating solutions based on our templates ensure that the Github secret scanning setting is enabled in your repos.
- Semantic Kernel Documentation
- Semantic Kernel Agent Framework Documentation
- Aspire Documentation
- Chat Protocol Documentation
- Initially based on Aspire Sample Application
- Idea from Creative Writing Assistant: Working with Agents using Prompty (Python Implementation)
This template, the application code and configuration it contains, has been built to showcase Microsoft Azure specific services and tools. We strongly advise our customers not to make this code part of their production environments without implementing or enabling additional security features.
For a more comprehensive list of best practices and security recommendations for Intelligent Applications, visit our official documentation.
This project is licensed under the terms of the MIT license. See the LICENSE.md
file for the full license text.