Skip to content

Commit 0ff3d63

Browse files
committed
updating acrolinux
1 parent e1c4d39 commit 0ff3d63

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

articles/app-service/deploy-intelligent-apps-dotnet-to-azure-sql.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ ms.collection: ce-skilling-ai-copilot
1111

1212
# Deploy a .NET Blazor app connected to Azure SQL and Azure OpenAI on Azure App Service
1313

14-
When creating intelligent apps, you may want to ground the context of your app using your own SQL data. With the recent announcement of [Azure SQL vector support (preview)](https://devblogs.microsoft.com/azure-sql/announcing-eap-native-vector-support-in-azure-sql-database/), you can ground the context using the Azure SQL data you already have with new [vector functions](https://learn.microsoft.com/en-us/sql/t-sql/functions/vector-functions-transact-sql?view=azuresqldb-current) that will help manage vector data.
14+
When creating intelligent apps, you may want to ground the context of your app using your own SQL data. With the recent announcement of [Azure SQL vector support (preview)](https://devblogs.microsoft.com/azure-sql/announcing-eap-native-vector-support-in-azure-sql-database/), you can ground the context using the Azure SQL data you already have with new [vector functions](https://learn.microsoft.com/en-us/sql/t-sql/functions/vector-functions-transact-sql?view=azuresqldb-current) that help manage vector data.
1515

16-
In this tutorial, you'll learn how to create a RAG sample application by setting up a Hybrid vector search against your Azure SQL database using a .NET 8 Blazor app. This example will build from the previous documentation to deploy a [.NET Blazor app with OpenAI](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet).
16+
In this tutorial, you'll create a RAG sample application by setting up a Hybrid vector search against your Azure SQL database using a .NET 8 Blazor app. This example builds from the previous documentation to deploy a [.NET Blazor app with OpenAI](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet).
1717

1818
#### Prerequisites
1919

2020
- An [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?pivots=programming-language-csharp&tabs=command-line%2Ckeyless%2Ctypescript-keyless%2Cpython#set-up) resource with deployed models
2121
- A .NET 8 or 9 Blazor Web App deployed on App Service
2222
- An Azure SQL database resource with vector embeddings.
2323

24-
### Setup Blazor web app
24+
### Set up Blazor web app
2525

26-
For this example, we'll be creating a simple chat box to interact with. If you're using the prerequisite .NET Blazor app from the [previous article](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet), you can skip the changes to the *OpenAI.razor* file as those are the same. However, you will need to make sure the following packages are installed:
26+
For this example, we are creating a simple chat box to interact with. If you're using the prerequisite .NET Blazor app from the [previous article](../azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet), you can skip the changes to the *OpenAI.razor* file as these are the same. However, you need to make sure the following packages are installed:
2727

2828
Install the following packages to interact with Azure OpenAI and Azure SQL.
2929

@@ -33,7 +33,7 @@ Install the following packages to interact with Azure OpenAI and Azure SQL.
3333
1. Right click on the **Pages** folder found under the **Components** folder and add a new item named *OpenAI.razor*
3434
2. Add the following code to the *OpenAI.razor* file and click **Save** to create the chat box
3535

36-
```html
36+
```csharp
3737
@page "/openai"
3838
@rendermode InteractiveServer
3939
@inject Microsoft.Extensions.Configuration.IConfiguration _config
@@ -59,11 +59,11 @@ Install the following packages to interact with Azure OpenAI and Azure SQL.
5959

6060
### API keys and endpoints
6161

62-
Using the Azure OpenAI resource requires the use of API keys and endpoint values. See the documentation in the previous article for setting up [Azure Key Vault references](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet#api-keys-and-endpoints) to manage and handle your secrets with Azure OpenAI. Although not required, we do recommend using managed identity to secure your client without the need to manage API keys. See the previous [documentation](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet#secure-your-app-with-managed-identity) to setup your Azure OpenAI client in the next step to use managed identity with Azure OpenAI.
62+
Using the Azure OpenAI resource requires the use of API keys and endpoint values. See the documentation in the previous article for setting up [Azure Key Vault references](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet#api-keys-and-endpoints) to manage and handle your secrets with Azure OpenAI. Although not required, we do recommend using managed identity to secure your client without the need to manage API keys. See the previous [documentation](https://learn.microsoft.com/en-us/azure/app-service/deploy-intelligent-apps?pivots=openai-dotnet#secure-your-app-with-managed-identity) to set up your Azure OpenAI client in the next step to use managed identity with Azure OpenAI.
6363

6464
### Add Azure OpenAI client
6565

66-
After adding the chat interface, we can setup the Azure OpenAI client using Semantic Kernel. Add the following code to create the client that will connect to your Azure OpenAI resource. You will need to use your Azure OpenAI API keys and endpoint information that were setup and handled in the previous step.
66+
After adding the chat interface, we can set up the Azure OpenAI client using Semantic Kernel. Add the following code to create the client that connects to your Azure OpenAI resource. You need to use your Azure OpenAI API keys and endpoint information that were set up and handled in the previous step.
6767

6868
```csharp
6969
@inject Microsoft.Extensions.Configuration.IConfiguration _config
@@ -130,25 +130,25 @@ After adding the chat interface, we can setup the Azure OpenAI client using Sema
130130
serverResponse = message;
131131
```
132132

133-
From here you should have a working chat application that is connected to OpenAI. Next, we will setup our Azure SQL database to work with our chat application.
133+
From here, you should have a working chat application that is connected to OpenAI. Next, we will set up our Azure SQL database to work with our chat application.
134134

135135
### Deploy Azure OpenAI models
136136

137-
In order to prepare your Azure SQL database for vector search, you will need to make use of an embedding model to generate embeddings used for searching in addition to your initial deployed chat model. For this example, we will be using the following models:
137+
In order to prepare your Azure SQL database for vector search, you need to make use of an embedding model to generate embeddings used for searching in addition to your initial deployed chat model. For this example, we are using the following models:
138138
- `text-embedding-ada-002` is used to generate the embeddings
139139
- `gpt-3.5-turbo` is used for the language model
140140

141-
These two models will need to be deployed before continuing the next step. Please visit the [documentation](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/deploy-models-openai) for deploying models with Azure OpenAI using Azure AI Foundry.
141+
These two models need to be deployed before continuing the next step. Visit the [documentation](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/deploy-models-openai) for deploying models with Azure OpenAI using Azure AI Foundry.
142142
143143
### Vectorize your SQL database
144144

145-
In order to perform a hybrid vector search on your Azure SQL database, you will first need to have the appropriate embeddings in your database. There are a number of ways you can vectorize your database. One option is to use the following [Azure SQL database vectorizer](https://github.com/Azure-Samples/azure-sql-db-vectorizer) to generate embeddings for your SQL database. Vectorize your Azure SQL database before continuing.
145+
To perform a hybrid vector search on your Azure SQL database, you first need to have the appropriate embeddings in your database. There are a number of ways you can vectorize your database. One option is to use the following [Azure SQL database vectorizer](https://github.com/Azure-Samples/azure-sql-db-vectorizer) to generate embeddings for your SQL database. Vectorize your Azure SQL database before continuing.
146146
147147
### Create procedure to generate embeddings
148148

149-
With [Azure SQL vector support (preview)](https://devblogs.microsoft.com/azure-sql/announcing-eap-native-vector-support-in-azure-sql-database/) you can create a stored procedure that will use a Vector data type to store generated embeddings for search queries. The stored procedure will invoke an external REST API endpoint to get the embeddings. See the [documentation](https://learn.microsoft.com/en-us/azure-data-studio/quickstart-sql-database) to use Azure Data Studio to connect to your database before running the query.
149+
With [Azure SQL vector support (preview)](https://devblogs.microsoft.com/azure-sql/announcing-eap-native-vector-support-in-azure-sql-database/), you can create a stored procedure that will use a Vector data type to store generated embeddings for search queries. The stored procedure invokes an external REST API endpoint to get the embeddings. See the [documentation](https://learn.microsoft.com/en-us/azure-data-studio/quickstart-sql-database) to use Azure Data Studio to connect to your database before running the query.
150150
151-
1. Use the following to create a stored procedure with your preferred SQL query editor. You will need to populate the @url parameter with your Azure OpenAI resource name and populate the rest endpoint with the API key from your text embedding model. You will also notice the model name as part of the @url. This will be populated with your search query.
151+
1. Use the following to create a stored procedure with your preferred SQL query editor. You need to populate the @url parameter with your Azure OpenAI resource name and populate the rest endpoint with the API key from your text embedding model. You will also notice the model name as part of the @url. This will be populated with your search query.
152152

153153
```sql
154154
CREATE PROCEDURE [dbo].[GET_EMBEDDINGS]
@@ -186,7 +186,7 @@ After creating your stored procedure, you should be able to view it under the **
186186
187187
### Connect and search your database
188188

189-
Now that your database is setup to create embeddings, we can connect to it in our application and setup the Hybrid vector search query.
189+
Now that your database is set up to create embeddings, we can connect to it in our application and set up the Hybrid vector search query.
190190

191191
Add the following code to your `OpenAI.razor` file and make sure the connection string is updated to use your deployed Azure SQL database connection string. You will notice the code is using a SQL parameter which will securely pass through the user input from the chat app to the query.
192192

@@ -268,14 +268,14 @@ catch (Exception e)
268268
Console.WriteLine("Done");
269269
```
270270

271-
The SQL query itself is using a hybrid search which executes the stored procedure setup previously to create embeddings and uses SQL to filter out your desired results. In this example, we are giving the results scores and ordering the output to grab the best results before using them as grounded context to generate a response from.
271+
The SQL query itself is using a hybrid search which executes the stored procedure set up previously to create embeddings and uses SQL to filter out your desired results. In this example, we are giving the results scores and ordering the output to grab the best results before using them as grounded context to generate a response from.
272272

273273
### Securing your data with Managed Identity
274274

275275
Azure SQL can leverage Managed Identity with Microsoft Entra to secure your SQL resource by configuring passwordless authentication. Follow the below steps to configure a passwordless connection string that will be used in your application.
276276

277277
1. Navigate to your Azure SQL server resource and click on Microsoft Entra ID under Settings.
278-
2. Then click on +**Set admin** and search and choose yourself to setup Entra ID and click **Save**. Now Entra ID is setup on your SQL server, and it will accept Entra ID authentication.
278+
2. Then click on +**Set admin** and search and choose yourself to set up Entra ID and click **Save**. Now Entra ID is set up on your SQL server, and accepts Entra ID authentication.
279279
3. Next, go to your database resource and copy the **ADO.NET (Microsoft Entra passwordless authentication)** connection string and add it to your code where you keep your connection string.
280280

281281
At this point, you can test your application locally with your passwordless connection string.
@@ -317,7 +317,7 @@ From here, your Azure SQL database is now secure, and you can deploy your applic
317317

318318
Here's the full example of the added *OpenAI.razor* page:
319319

320-
```sql
320+
```csharp
321321
@page "/openai"
322322
@rendermode InteractiveServer
323323
@inject Microsoft.Extensions.Configuration.IConfiguration _config

0 commit comments

Comments
 (0)