百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

azure-search-openai-demo-csharp

> AI 编程
开源

一个在 Azure 中运行的基于检索增强生成模式的示例应用程序,使用 Azure 认知搜索进行检索,以及 Azure 和 OpenAI 大型语言模型。

838 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个在 Azure 中运行的基于检索增强生成模式的示例应用程序,使用 Azure 认知搜索进行检索,以及 Azure 和 OpenAI 大型语言模型。


page_type: sample languages:

  • azdeveloper
  • csharp
  • html
  • bicep products:
  • ai-services
  • azure-blob-storage
  • azure-container-apps
  • azure-cognitive-search
  • azure-openai
  • aspnet-core
  • blazor
  • defender-for-cloud
  • azure-monitor
  • dotnet-maui urlFragment: azure-search-openai-demo-csharp name: ChatGPT + Enterprise data (csharp) description: A csharp sample app that chats with your data using OpenAI and AI Search.

Table of Contents

  • Features
  • Application Architecture
  • Azure account requirements
  • Getting Started
    • Cost estimation
    • Project setup
      • GitHub Codespaces
      • VS Code Dev Containers
      • Local environment
    • Deployment
      • Deploying from scratch
      • Deploying with existing Azure resources
      • Deploying again
      • Deploying App Spaces
      • Running locally
      • Sharing environments
      • Clean up resources
    • Using the app
  • Enabling optional features
    • Enabling Application Insights
    • Enabling authentication
    • Enable GPT-4V support
  • Guidance
    • Productionizing
    • Resources
    • FAQ

ChatGPT + Enterprise data with Azure OpenAI and Azure AI Search (.NET)

This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (gpt-4o-mini), and Azure AI Search for data indexing and retrieval.

The repo includes sample data so it's ready to try end-to-end. In this sample application, we use a fictitious company called Contoso Electronics, and the experience allows its employees to ask questions about the benefits, internal policies, as well as job descriptions and roles.

For more details on how this application was built, check out:

  • Transform your business with smart .NET apps powered by Azure and ChatGPT blog post
  • Build Intelligent Apps with .NET and Azure - Build Session

We want to hear from you! Are you interested in building or currently building intelligent apps? Take a few minutes to complete this survey.

Take the survey

Features

  • Voice Chat, Chat and Q&A interfaces
  • Explores various options to help users evaluate the trustworthiness of responses with citations, tracking of source content, etc.
  • Shows possible approaches for data preparation, prompt construction, and orchestration of interaction between model (ChatGPT) and retriever (Azure AI Search)
  • Settings directly in the UX to tweak the behavior and experiment with options

Application architecture

  • User interface - The application’s chat interface is a Blazor WebAssembly application. This interface is what accepts user queries, routes request to the application backend, and displays generated responses.
  • Backend - The application backend is an ASP.NET Core Minimal API. The backend hosts the Blazor static web application and what orchestrates the interactions among the different services. Services used in this application include:
    • Azure AI Search – indexes documents from the data stored in an Azure Storage Account. This makes the documents searchable using vector search capabilities.
    • Azure OpenAI Service – provides the Large Language Models to generate responses. Semantic Kernel is used in conjunction with the Azure OpenAI Service to orchestrate the more complex AI workflows.

Getting Started

Account Requirements

In order to deploy and run this example, you'll need

  • Azure Account - If you're new to Azure, get an Azure account for free and you'll get some free Azure credits to get started.
  • Azure account permissions - Your Azure Account must have Microsoft.Authorization/roleAssignments/write permissions, such as User Access Administrator or Owner.

[!WARNING]

By default this sample will create an Azure Container App, and Azure AI Search resource that have a monthly cost, as well as Azure AI Document Intelligence resource that has cost per document page. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though there are some limits to consider; for example, you can have up to 1 free Azure AI Search resource per subscription, and the free Azure AI Document Intelligence resource only analyzes the first 2 pages of each document.)

Cost estimation

Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage. However, you can try the Azure pricing calculator for the resources below:

  • Azure Container Apps. Environment type: Consumption Only. The solution uses the Consumption plan, as we don't have specific hardware requirements.
  • Azure OpenAI Service. Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question.
  • Azure AI Document Intelligence. SO (Standard) tier using pre-built layout. Pricing per document page, sample documents have 261 pages total.
  • Azure AI Search Basic tier, 1 replica, free level of semantic search. Pricing per hour.
  • Azure Blob Storage. Standard tier with ZRS (Zone-redundant storage). Pricing per storage and read operations.
  • Azure Monitor. Pay-as-you-go tier. Costs based on data ingested.

To reduce costs, you can switch to free SKUs for various services, but those SKUs have limitations. See this guide on deploying with minimal costs for more details.

⚠️ 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.

Project setup

You have a few options for setting up this project. The easiest way to get started is GitHub Codespaces, since it will setup all the tools for you, but you can also set it up locally if desired.

GitHub Codespaces

You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:

VS Code Remote Containers

A related option is VS Code Remote Containers, which will open the project in your local VS Code using the Dev Containers extension:

Local environment

Install the following prerequisites:

  • Azure Developer CLI

  • .NET 8

  • Git

  • Powershell 7+ (pwsh) - For Windows users only.

    Important: Ensure you can run pwsh.exe from a PowerShell command. If this fails, you likely need to upgrade PowerShell.

  • Docker

    Important: Ensure Docker is running before running any azd provisioning / deployment commands.

Then, run the following commands to get the project on your local environment:

  1. Run azd auth login
  2. Clone the repository or run azd init -t azure-search-openai-demo-csharp
  3. Run azd env new azure-search-openai-demo-csharp

Deployment

Deploying from scratch

Live stream: Deploying from scratch in CodeSpaces Live stream: Deploying from scratch in Windows 11

Important: Ensure Docker is running before running any azd provisioning / deployment commands.

Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.

  1. Run azd up - This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the ./data folder.

    • For the target location, the regions that currently support the model used in this sample are East US. For an up-to-date list of regions and models, check here
    • If you have access to multiple Azure subscriptions, you will be prompted to select the subscription you want to use. If you only have access to one subscription, it will be selected automatically.

    Note: This application uses the gpt-4o-mini model. When choosing which region to deploy to, make sure they're available in that region (i.e. EastUS). For more information, see the Azure OpenAI Service documentation.

  2. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.

It will look like the following:

[!NOTE]: It may take a few minutes for the application to be fully deployed. After the application is deployed, it will also take a few minutes to process the documents to be added into the vector database.

Use existing resources

If you have existing resources in Azure that you wish to use, you can configure azd to use those by setting the following azd environment variables:

  1. Run azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
  2. Run azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
  3. Run azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}. Only needed if your ChatGPT deployment is not the default 'chat'.
  4. Run azd env set AZURE_OPENAI_EMBEDDING_DEPLOYMENT {Name of existing embedding model deployment}. Only needed if your embedding model deployment is not the default embedding.
  5. Run azd up

[!NOTE]

You can also use existing Search and Storage Accounts. See ./infra/main.parameters.json for list of environment variables to pass to azd env set to configure those existing resources.

Deploying or re-deploying a local clone of the repo

[!IMPORTANT]

Ensure Docker is running before running any azd provisioning / deployment commands.

  • Run azd up

Deploying your repo using App Spaces

[!NOTE]

Make sure you have AZD supported bicep fi

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#ai-azd-templatesazd-templatesazurechatgpt

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.