- Overview
- Features
- Pre-Requisites
- Getting Started
- Development
- Testing
- Guidance
- Resources
- Code of Conduct
- Responsible AI Guidelines
This project implements an intelligent assistant that showcases:
- Azure AI Foundry SDK for building, deploying, and managing AI applications at scale
- Azure AI Agents for orchestrating complex tasks and building extensible AI solutions
- A Chainlit-based chat interface for interactive user engagement
- FastAPI endpoints for programmatic access
The project provides the following features:
- Chainlit for creating interactive chat interfaces
- Azure OpenAI for advanced language model capabilities
- Azure AI Search for semantic search and information retrieval
- Azure AI Agents for task orchestration
- FastAPI for REST API endpoints
- Azure Container Apps for cloud-native application hosting
- Docker containerization for deployment flexibility
It also comes with:
- Sample implementation of both chat and API interfaces
- Development environment setup with VS Code
- Azure service integration examples
- Deployment configurations for Azure
- Pre-populated with Contoso sample data (customizable for your specific data needs)
To deploy and explore the sample, you will need:
- An active Azure subscription - Signup for a free account here
- Azure OpenAI Services - Learn about Azure OpenAI
- Azure AI Search service - Learn more about AI Search
- Available Quota for GPT models in your preferred region
From a tooling perspective, familiarity with the following is useful:
- Visual Studio Code (and extensions)
- Python and FastAPI
- Docker and containerization
- Azure services and deployment
You have two options for setting up your development environment:
- Use GitHub Codespaces - for a prebuilt dev environment in the cloud
- Use Docker Desktop - for a prebuilt dev environment on local device
Choose the option that best suits your needs and development style.
-
You can run this template virtually by using GitHub Codespaces. Click this button to open a web-based VS Code instance in your browser:
-
Once the codespaces environment is ready (this can take several minutes), open a new terminal in that VS Code instance - and proceed to the Development step.
A related option is to use VS Code Dev Containers, which will open the project in your local Visual Studio Code editor using the Dev Containers extension:
-
Install Docker Desktop (if not installed), then start it.
-
Open the project in your local VS Code by clicking the button below:
-
Once the VS Code window shows the project files (this can take several minutes), open a new terminal in that VS Code instance - and proceed to the Development step.
Once you've completed the setup the project (using Codespaces, Dev Containers), you should now have a Visual Studio Code editor open, with the project files loaded, and a terminal open for running commands. Let's verify that all required tools are installed.
az version
azd version
python --versionWe can now proceed with next steps - click to expand for detailed instructions.
1️⃣ | Authenticate With Azure
-
Open a VS Code terminal and authenticate with Azure CLI. Use the
--use-device-codeoption if authenticating from GitHub Codespaces. Complete the auth workflow as guided.az login --use-device-code
-
Now authenticate with Azure Developer CLI in the same terminal. Complete the auth workflow as guided.
azd auth login --use-device-code
-
You should see: Logged in on Azure. This will create a folder under
.azure/in your project to store the configuration for this deployment. You may have multiple azd environments if desired.
2️⃣ | Provision-Deploy with AZD
-
Run
azd upto provision infrastructure and deploy the application, with one command. (You can also useazd provision,azd deployseparately if needed)azd up
-
You will be asked for a subscription for provisioning resources, an environment name that maps to the resource group, and a location for deployment. Refer to the Region Availability guidance to select the region that has the desired models and quota available.
-
The
azd upcommand can take 15-20 minutes to complete. Successful completion sees aSUCCESS: ...messages posted to the console. We can now validate the outcomes.
3️⃣ | Validate and Deploy
-
Test the FastAPI backend:
- Get the API URL from the
azd upoutput - Visit
https://<your-api-app>.azurecontainerapps.io/docsin your browser - You should see the Swagger UI documentation
- Test the
/api/testendpoint with a sample query - Verify that responses from Azure OpenAI are working
- Get the API URL from the
-
Test the Chainlit interface:
- Get the Chainlit URL from the
azd upoutput - Visit
https://<your-chainlit-app>.azurecontainerapps.ioin your browser - You should see the Chainlit chat interface
- Try a test conversation
- Verify that the chat responses are working correctly
- Get the Chainlit URL from the
✅ | Congratulations! - Your development environment is ready!
To test the application in your local environment:
-
Start the FastAPI backend:
./start_fastapi.sh ``` This will start the API server on http://localhost:8000 -
Start the Chainlit interface:
./start_chainlit.sh
-
Testing the Components:
- For API: Access http://localhost:8000/docs to test endpoints via Swagger UI
- For Chat: Access http://localhost to test the chat interface
- Try different types of queries to ensure proper handling
- Verify Azure service integrations are working correctly
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 model. Pricing is based on token count.
- 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.
- Azure Container Registry: Basic tier.
- Log analytics: Pay-as-you-go tier. Costs based on data ingested.
azd down.
This repository contains sample code and guidance for demonstration and learning purposes. It is not intended for production use without proper review and adaptation.
Before deploying to production:
- Ensure proper security measures are implemented
- Add appropriate error handling and logging
- Test thoroughly in your environment
- Follow your organization's deployment and security guidelines
This template uses Managed Identity for all Azure service communication.
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.
Consider implementing these additional security measures:
- Enable Microsoft Defender for Cloud to secure your Azure resources
- Protect the Azure Container Apps instance with:
- Chainlit Documentation
- Azure OpenAI Documentation
- Azure AI Search Documentation
- Azure AI Agents Documentation
- FastAPI Documentation
This project has adopted the Microsoft Open Source Code of Conduct. Learn more here:
- Microsoft Code of Conduct FAQ
- Contact [email protected] with questions or concerns
This project follows Microsoft's responsible AI guidelines and best practices: