languages | products | page_type | name | urlFragment | description | ||||
---|---|---|---|---|---|---|---|---|---|
|
|
sample |
.NET Aspire Shop and Semantic Kernel sample |
AspireShopWithSK |
An example shop app with assistant written with .NET Aspire and Semantic Kernel |
This project is a modified version of the Aspire Shop sample with the addition of an intelligent assistant powered by Semantic Kernel. The assistant is available in the form of a chat service that can be accessed from the web front end.
The app consists of four services:
- AspireShop.Frontend: This is a Blazor app that displays a paginated catlog of products and allows users to add products to a shopping cart.
- AspireShop.CatalogService: This is an HTTP API that provides access to the catalog of products stored in a PostgreSQL database.
- AspireShop.CatalogDbManager: This is an HTTP API that manages the initialization and updating of the catalog database.
- AspireShop.BasketService: This is a gRPC service that provides access to the shopping cart stored in Redis.
- NEW! AspireShop.ChatService: This is an HTTP API that provides an intelligent assistant to help users with their shopping experience.
The app also includes a class library project, AspireShop.ServiceDefaults, that contains the service defaults used by the service projects.
Edit the appsettings.Development.json
file in the AspireShop.AppHost
project to point to the correct values as follows:
When using Azure OpenAI, use and update these values:
"Parameters" : {
"ChatDeploymentName": "Replace this with your Azure OpenAI Chat Deployment",
"ChatEndpoint": "Replace this with your Azure OpenAI Endpoint",
"ChatApiKey": "Replace this with your Azure OpenAI or OpenAI Api Key"
}
When using OpenAI, use and update these values:
"Parameters" : {
"ChatApiKey": "Replace this with your OpenAI Api Key",
"ChatModelId": "Replace this with your OpenAI Model Id"
}
If using Visual Studio, open the solution file AspireShop.sln
and launch/debug the AspireShop.AppHost
project.
If using the .NET CLI, run dotnet run
from the AspireShop.AppHost
directory.
Alternatively, you can use devcontainer to run and debug the app via a container. Open the project in Visual Studio Code and select Reopen in Container
from the context menu.
Consult your IDE/Text Editor documentation for more information on how to run the app using devcontainer.
To deploy the app to Azure, you can use one of the following options:
Note
This section will create Azure resources and deploy the solution from your local environment using the Azure Developer CLI. Note that you do not need to clone this repo to complete these steps.
azd init -t vicperdana/AspireShopWithSemanticKernel
azd up
# if you are wanting to see logs run with debug
azd up --debug
Important
This section is work in progress 🚧.
Note
This section will create Azure resources and deploy the solution from your GitHub repository using GitHub Actions. Note that you need to fork this repo to complete these steps.
- Fork this repository.
- Run the following commands
cd /your/repo/path
azd init
The following prompt will appear:
Initializing an app to run on Azure (azd init)
? Enter a new environment name: [? for help]
# Select Use code in the current directory when azd prompts you with two app initialization options.
? How do you want to initialize your app? [Use arrows to move, type to filter]
> Use code in the current directory
Select a template
Select the Confirm and continue initializing my app option.
Detected services:
.NET (Aspire)
Detected in: D:\source\repos\AspireSample\AspireSample.AppHost\AspireSample.AppHost.csproj
azd will generate the files necessary to host your app on Azure using Azure Container Apps.
? Select an option [Use arrows to move, type to filter]
> Confirm and continue initializing my app
Cancel and exit
Generating files to run your app on Azure:
(✓) Done: Generating ./azure.yaml
(✓) Done: Generating ./next-steps.md
SUCCESS: Your app is ready for the cloud!
You can provision and deploy your app to Azure by running the azd up command in this directory. For more information on configuring your app, see ./next-steps.md
- Create the GitHub pipeline Run this command to configure your deployment pipeline and securely connect it to Azure and provide secret parameters.
>> azd pipeline config
? Select an Azure Subscription to use:
? Select an Azure location to use:
? Enter a value for the 'chatApiKey' infrastructure secured parameter: ********************************
? Enter a value for the 'chatDeploymentName' infrastructure secured parameter: *****
? Enter a value for the 'chatEndpoint' infrastructure secured parameter: *************************************
Configure your GitHub pipeline
(✓) Done: Checking current directory for Git repository
(✓) Done: Creating service principal xxx (xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx)
(✓) Done: Federated identity credential for GitHub: subject repo:owner/AspireShopWithSK:pull_request
(✓) Done: Federated identity credential for GitHub: subject repo:owner/AspireShopWithSK:ref:refs/heads/main
(✓) Done: Setting AZURE_ENV_NAME repo variable
(✓) Done: Setting AZURE_LOCATION repo variable
(✓) Done: Setting AZURE_SUBSCRIPTION_ID repo variable
(✓) Done: Setting AZURE_TENANT_ID repo variable
(✓) Done: Setting AZURE_CLIENT_ID repo variable
GitHub Action secrets are now configured. You can view GitHub action secrets that were created at this link:
https://github.com/vicperdana/AspireShopWithSK/settings/secrets/actions
? Would you like to commit and push your local changes to start the configured CI pipeline? (Y/n) Y
(✓) Done: Pushing changes
(✓) Done: Queuing pipeline
SUCCESS: Your GitHub pipeline has been configured!
See the presentation slides and the video below for more information on the project.
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the Aspire Shop sample as the basis. Additionally, the following resources were used as references: