Skip to content

Azure-Samples/get-started-with-ai-chat

Get Started with Chat Using Azure AI Foundry

Solution Overview

This solution deploys a web-based chat application with AI capabilities running in Azure Container App.

The application leverages Azure AI Foundry projects and Azure AI services to provide intelligent chat functionality. It supports both direct AI model interaction and Retrieval-Augmented Generation (RAG) using Azure AI Search for knowledge retrieval from uploaded files, enabling it to generate responses with citations. The solution also includes built-in monitoring capabilities with tracing to ensure easier troubleshooting and optimized performance.

This solution creates an Azure AI Foundry project and Azure AI services. More details about the resources can be found in the resources documentation. There are options to enable RAG, logging, tracing, and monitoring.

Instructions are provided for deployment through GitHub Codespaces, VS Code Dev Containers, and your local development environment.

Solution Architecture

Architecture diagram showing that user input is provided to the Azure Container App, which contains the app code. With user identity and resource access through managed identity, the input is used to form a response. The input and the Azure monitor are able to use the Azure resources deployed in the solution: Application Insights, Azure AI Project, Azure AI Services, Azure AI Hub, Storage account, Azure Container App, Container Registry, Key Vault, Log Analytics Workspace, and Search Service.

The app code runs in Azure Container Apps to process the user input and generate a response to the user. It leverages Azure AI projects and Azure AI services, including the model and search service.

Key Features

Knowledge Retrieval: The AI chat application supports Retrieval-Augmented Generation (RAG) using Azure AI Search to retrieve knowledge from uploaded files, enabling contextual responses with citations.

Customizable AI Model Deployment: The solution allows users to configure and deploy AI models, such as gpt-4o-mini, with options to adjust model capacity, deployment configurations, and knowledge retrieval methods.

Built-in Monitoring and Tracing: Integrated monitoring capabilities, including Azure Monitor and Application Insights, enable tracing and logging for easier troubleshooting and performance optimization.

Flexible Deployment Options: The solution supports deployment through GitHub Codespaces, VS Code Dev Containers, or local environments, providing flexibility for different development workflows.

Here is a screenshot showing the chatting web application with requests and responses between the system and the user:

Screenshot of chatting web application showing requests and responses between assistants and the user.

WARNING: 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.

Getting Started

Quick Deploy

Open in GitHub Codespaces Open in Dev Containers

Github Codespaces and Dev Containers both allow you to download and deploy the code for development. You can also continue with local development. Once you have selected your environment, click here to launch the development and deployment guide

After deployment, try these sample questions to test your web application.

Local Development

For developers who want to run the application locally or customize the chat application:

Local Development Guide - Set up a local development environment, customize the frontend and backend, modify AI model configurations, and test your changes locally.

This guide covers:

• Environment setup and prerequisites • Running the development server locally
• Frontend customization and backend communication • AI model and RAG configuration • Embedding file upload • Testing and debugging your application

Other Features

Once you have the web app working, you are encouraged to try one of the following:

  • Tracing and Monitoring - View console logs in Azure portal and App Insights tracing in Azure AI Foundry for debugging and performance monitoring.

Resource Clean-up

To prevent incurring unnecessary charges, it's important to clean up your Azure resources after completing your work with the application.

  • When to Clean Up:

    • After you have finished testing or demonstrating the application.
    • If the application is no longer needed or you have transitioned to a different project or environment.
    • When you have completed development and are ready to decommission the application.
  • Deleting Resources: To delete all associated resources and shut down the application, execute the following command:

    azd down

    Please note that this process may take up to 20 minutes to complete.

⚠️ Alternatively, you can delete the resource group directly from the Azure Portal to clean up resources.

Guidance

Costs

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 AI Foundry: Free tier. Pricing
  • Azure AI Search: Standard tier, S1. Pricing is based on the number of documents and operations. Pricing
  • Azure Storage Account: Standard tier, LRS. Pricing is based on storage and operations. Pricing
  • Azure AI Services: S0 tier, defaults to gpt-4o-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

⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use, either by deleting the resource group in the Portal or running azd down.

Security guidelines

This template also uses Managed Identity for local development and deployment.

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:

Important Security Notice
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.

Resources

This template creates everything you need to get started with Azure AI Foundry:

Resource Description
Azure AI Project Provides a collaborative workspace for AI development with access to models, data, and compute resources
Azure OpenAI Service Powers the AI agents for conversational AI and intelligent search capabilities. Default models deployed are gpt-4o-mini, but any Azure AI models can be specified per the documentation
Azure Container Apps Hosts and scales the web application with serverless containers
Azure Container Registry Stores and manages container images for secure deployment
Storage Account Provides blob storage for application data and file uploads
AI Search Service Optional - Enables hybrid search capabilities combining semantic and vector search
Application Insights Optional - Provides application performance monitoring, logging, and telemetry for debugging and optimization
Log Analytics Workspace Optional - Collects and analyzes telemetry data for monitoring and troubleshooting