You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Purpose
Fix documentation related issues. Tracked in #174Fixes#133Fixes#171Fixes#173Fixes#176
## Does this introduce a breaking change?
<!-- Mark one with an "x". -->
```
[ ] Yes
[x] No
```
## Pull Request Type
What kind of change does this Pull Request introduce?
<!-- Please check the one that applies to this PR using "x". -->
```
[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Documentation content changes
[ ] Other... Please describe:
```
## How to Test
* Get the code
```
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
```
* Test the code
<!-- Add steps to run the tests suite and/or manually test -->
```
```
## What to Check
Verify that the following are valid
* ...
## Other Information
<!-- Add any other helpful information that may be needed here. -->
---------
Co-authored-by: Aaron Powell <[email protected]>
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=624102171&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
@@ -8,7 +24,7 @@ This sample demonstrates a few approaches for creating ChatGPT-like experiences
8
24
9
25
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:
14
30
@@ -28,63 +44,90 @@ We want to hear from you! Are you interested in building or currently building i
28
44
29
45

30
46
47
+
## Application architecture
48
+
49
+
-**User interface** - The application’s chat interface is a [Blazor WebAssembly](https://learn.microsoft.com/aspnet/core/blazor/) application. This interface is what accepts user queries, routes request to the application backend, and displays generated responses.
50
+
-**Backend** - The application backend is an [ASP.NET Core Minimal API](https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/overview). The backend hosts the Blazor static web application and what orchestrates the interactions among the different services. Services used in this application include:
51
+
-[**Azure Cognitive Search**](https://learn.microsoft.com/azure/search/search-what-is-azure-search) – indexes documents from the data stored in an Azure Storage Account. This makes the documents searchable using [vector search](https://learn.microsoft.com/azure/search/search-get-started-vector) capabilities.
52
+
-[**Azure OpenAI Service**](https://learn.microsoft.com/azure/ai-services/openai/overview) – provides the Large Language Models to generate responses. [Semantic Kernel](https://learn.microsoft.com/semantic-kernel/whatissk) is used in conjunction with the Azure OpenAI Service to orchestrate the more complex AI workflows.
53
+
31
54
## Getting Started
32
55
33
-
> **Note**<br>
34
-
> In order to deploy and run this example, you'll need an **Azure subscription with access enabled for the Azure OpenAI service**. You can request access [here](https://aka.ms/oaiapply). You can also visit [here](https://azure.microsoft.com/free/cognitive-search/) to get some free Azure credits to get you started.
56
+
### Account Requirements
57
+
58
+
In order to deploy and run this example, you'll need
59
+
60
+
-**Azure Account** - If you're new to Azure, get an [Azure account for free](https://aka.ms/free) and you'll get some free Azure credits to get started.
61
+
-**Azure subscription with access enabled for the Azure OpenAI service** - [You can request access](https://aka.ms/oaiapply). You can also visit [the Cognitive Search docs](https://azure.microsoft.com/free/cognitive-search/) to get some free Azure credits to get you started.
62
+
-**Azure account permissions** - Your Azure Account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator) or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner).
63
+
35
64
36
65
> **Warning**<br>
37
-
> By default this sample will create an Azure App Service, Azure Static Web App, and Azure Cognitive Search resource that have a monthly cost, as well as Form Recognizer 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 Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.)
66
+
> By default this sample will create an Azure Container App, and Azure Cognitive Search resource that have a monthly cost, as well as Form Recognizer 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 Cognitive Search resource per subscription, and the free Form Recognizer resource only analyzes the first 2 pages of each document.)
67
+
68
+
### Cost estimation
69
+
70
+
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](https://azure.microsoft.com/pricing/calculator/) for the resources below:
#### GitHub Codespaces or VS Code Remote Containers
81
+
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](#local-environment) if desired.
42
82
43
-
You can run this repo virtually by using GitHub Codespaces or VS Code Remote Containers. When using GitHub Codespaces or VS Code Remote Containers all the required software will be installed in the container.
83
+
#### GitHub Codespaces
44
84
45
-
Click on one of the buttons below to open this repo in one of those options.
85
+
You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:
46
86
47
87
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=624102171&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=WestUs2)
48
-
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/azure-search-openai-demo-csharp)
49
88
50
-
##### Project Initialization
89
+
####VS Code Remote Containers
51
90
52
-
1. Run `azd auth login`
53
-
1. Run `azd env new azure-search-openai-demo-csharp`
91
+
A related option is VS Code Remote Containers, which will open the project in your local VS Code using the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension:
92
+
93
+
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/azure-search-openai-demo-csharp)
-**Important**: Ensure Docker is running before running any `azd` provisioning / deployment commands.
66
108
67
-
##### Project Initialization
109
+
> **Important**<br>
110
+
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
68
111
69
-
1. Create a new folder and switch to it in the terminal
70
-
1. Run `azd auth login`
71
-
1. Run `azd init -t azure-search-openai-demo-csharp`
112
+
Then, run the following commands to get the project on your local environment:
72
113
73
-
> **Note**<br>
74
-
> Your Azure Account must have `Microsoft.Authorization/roleAssignments/write` permissions, such as [User Access Administrator](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator) or [Owner](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner).
114
+
1. Run `azd auth login`
115
+
1. Clone the repository or run `azd init -t azure-search-openai-demo-csharp`
116
+
1. Run `azd env new azure-search-openai-demo-csharp`
75
117
76
-
### Installation
118
+
### Deploying from scratch
77
119
78
-
#### Starting from scratch
120
+
> **Important**<br>
121
+
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
79
122
80
123
Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.
81
124
82
125
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.
83
126
- For the target location, the regions that currently support the model used in this sample are **East US 2** , **East US** or **South Central US**. For an up-to-date list of regions and models, check [here](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models)
84
127
- 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.
85
128
86
-
> **Note**<br>
87
-
> This application uses the `gpt-35-turbo` 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](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#gpt-35-models).
129
+
> **Note**<br>
130
+
> This application uses the `gpt-35-turbo` 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](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#gpt-35-models).
88
131
89
132
1. 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.
90
133
@@ -102,13 +145,17 @@ If you have existing resources in Azure that you wish to use, you can configure
102
145
1. Run `azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}`
103
146
1. Run `azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}`
104
147
1. Run `azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}`. Only needed if your ChatGPT deployment is not the default 'chat'.
105
-
1. Run `azd env set AZURE_OPENAI_GPT_DEPLOYMENT {Name of existing GPT deployment}`. Only needed if your ChatGPT deployment is not the default `davinci`.
148
+
1. 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`.
106
149
1. Run `azd up`
107
150
108
-
> 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.
151
+
> **Note**<br>
152
+
> 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.
109
153
110
154
#### Deploying or re-deploying a local clone of the repo
111
155
156
+
> **Important**<br>
157
+
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
158
+
112
159
- Run `azd up`
113
160
114
161
#### Deploying your repo using App Spaces
@@ -149,6 +196,9 @@ If you have existing resources in Azure that you wish to use, you can configure
149
196
150
197
#### Running locally
151
198
199
+
> **Important**<br>
200
+
> Ensure Docker is running before running any `azd` provisioning / deployment commands.
201
+
152
202
1. Run `azd auth login`
153
203
1. After the application deploys, set the environment variable `AZURE_KEY_VAULT_ENDPOINT`. You can find the value in the _.azure/YOUR-ENVIRONMENT-NAME/.env_ file or the Azure portal.
154
204
1. Run the following .NET CLI command to start the ASP.NET Core Minimal API server (client host):
@@ -172,19 +222,55 @@ Run the following if you want to give someone else access to the deployed and ex
172
222
173
223
Run `azd down`
174
224
175
-
### Quickstart
225
+
### Using the app
176
226
177
-
- In Azure: navigate to the Azure Static Web App deployed by `azd`. The URL is printed out when `azd` completes (as "Endpoint"), or you can find it in the Azure portal.
227
+
- In Azure: navigate to the Azure Container App deployed by `azd`. The URL is printed out when `azd` completes (as "Endpoint"), or you can find it in the Azure portal.
178
228
- When running locally, navigate to <http://localhost:7181> for the client app and <http://localhost:7181/swagger> for the Open API server page.
179
229
180
230
Once in the web app:
181
231
182
232
- On the **Voice Chat** page, select the voice settings dialog and configure text-to-speech preferences.
183
233
- You can either type messages to interact with Blazor Clippy, or select the Speak toggle button to use speech-to-text as your input.
184
-
- Try different topics in **Chat**or **Ask Questions**context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
234
+
- Try different topics in **Chat** context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
185
235
- Explore citations and sources
186
236
- Click on the "settings" icon to try different options, tweak prompts, etc.
187
237
238
+
## Enabling optional features
239
+
240
+
### Enabling Application Insights
241
+
242
+
To enable Application Insights and the tracing of each request, along with the logging of errors, set the `AZURE_USE_APPLICATION_INSIGHTS` variable to true before running `azd up`
243
+
244
+
1. Run `azd env set AZURE_USE_APPLICATION_INSIGHTS true`
245
+
1. Run `azd up`
246
+
247
+
To see the performance data, go to the Application Insights resource in your resource group, click on the "Investigate -> Performance" blade and navigate to any HTTP request to see the timing data.
248
+
To inspect the performance of chat requests, use the "Drill into Samples" button to see end-to-end traces of all the API calls made for any chat request:
To see any exceptions and server errors, navigate to the "Investigate -> Failures" blade and use the filtering tools to locate a specific exception. You can see Python stack traces on the right-hand side.
253
+
254
+
### Enabling authentication
255
+
256
+
By default, the deployed Azure container app will have no authentication or access restrictions enabled, meaning anyone with routable network access to the container app can chat with your indexed data. You can require authentication to your Azure Active Directory by following the [Add container app authentication](https://learn.microsoft.com/azure/container-apps/authentication-azure-active-directory) tutorial and set it up against the deployed container app.
257
+
258
+
To then limit access to a specific set of users or groups, you can follow the steps from [Restrict your Azure AD app to a set of users](https://learn.microsoft.com/azure/active-directory/develop/howto-restrict-your-app-to-a-set-of-users) by changing "Assignment Required?" option under the Enterprise Application, and then assigning users/groups access. Users not granted explicit access will receive the error message -AADSTS50105: Your administrator has configured the application <app_name> to block users unless they are specifically granted ('assigned') access to the application.-
259
+
260
+
## Productionizing
261
+
262
+
This sample is designed to be a starting point for your own production application,
263
+
but you should do a thorough review of the security and performance before deploying
264
+
to production. Here are some things to consider:
265
+
266
+
***OpenAI Capacity**: The default TPM (tokens per minute) is set to 30K. That is equivalent to approximately 30 conversations per minute (assuming 1K per user message/response). You can increase the capacity by changing the `chatGptDeploymentCapacity` and `embeddingDeploymentCapacity` parameters in `infra/main.bicep` to your account's maximum capacity. You can also view the Quotas tab in [Azure OpenAI studio](https://oai.azure.com/) to understand how much capacity you have.
267
+
***Azure Storage**: The default storage account uses the `Standard_LRS` SKU. To improve your resiliency, we recommend using `Standard_ZRS` for production deployments, which you can specify using the `sku` property under the `storage` module in `infra/main.bicep`.
268
+
***Azure Cognitive Search**: If you see errors about search service capacity being exceeded, you may find it helpful to increase the number of replicas by changing `replicaCount` in `infra/core/search/search-services.bicep` or manually scaling it from the Azure Portal.
269
+
***Azure Container Apps**: By default, this application deploys containers with 0.5 CPU Cores and 1GB of memory. The minimum replicas is 1 and maximum 10. For this app, you can set values such as `containerCpuCoreCount`, `containerMaxReplicas `, `containerMemory`, `containerMinReplicas` in the `infra/core/host/container-app.bicep` file to fit your needs. You can use auto-scaling rules or scheduled scaling rules, and scale up the [maximum/minimum](https://learn.microsoft.com/azure/container-apps/scale-app) based on load.
270
+
***Authentication**: By default, the deployed app is publicly accessible. We recommend restricting access to authenticated users. See [Enabling authentication](#enabling-authentication) above for how to enable authentication.
271
+
***Networking**: We recommend deploying inside a Virtual Network. If the app is only for internal enterprise use, use a private DNS zone. Also consider using Azure API Management (APIM) for firewalls and other forms of protection. For more details, read [Azure OpenAI Landing Zone reference architecture](https://techcommunity.microsoft.com/t5/azure-architecture-blog/azure-openai-landing-zone-reference-architecture/ba-p/3882102).
272
+
***Loadtesting**: We recommend running a loadtest for your expected number of users.
273
+
188
274
## Resources
189
275
190
276
-[Revolutionize your Enterprise Data with ChatGPT: Next-gen Apps w/ Azure OpenAI and Cognitive Search](https://aka.ms/entgptsearchblog)
0 commit comments