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
Copy file name to clipboardExpand all lines: articles/azure-functions/functions-add-openai-text-completion.md
+35-29Lines changed: 35 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: 'Tutorial: Connect to OpenAI from Azure Functions in Visual Studio Code'
3
3
description: Learn how to connect Azure Functions to OpenAI by adding an output binding to your Visual Studio Code project.
4
-
ms.date: 5/30/2024
4
+
ms.date: 07/02/2024
5
5
ms.topic: tutorial
6
6
author: dbandaru
7
7
ms.author: dbandaru
@@ -22,7 +22,7 @@ This article shows you how to use Visual Studio Code to connect Azure OpenAI to
22
22
> * Enable your function app to connect to OpenAI.
23
23
> * Add OpenAI bindings to your HTTP triggered function.
24
24
25
-
## Prerequisites
25
+
## 0. Prerequisites
26
26
:::zone pivot="programming-language-csharp"
27
27
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-csharp.md).
28
28
:::zone-end
@@ -44,7 +44,9 @@ This article shows you how to use Visual Studio Code to connect Azure OpenAI to
44
44
* Obtain access to Azure OpenAI in your Azure subscription. If you haven't already been granted access, complete [this form](https://aka.ms/oai/access) to request access.
* The [Azurite storage emulator](../storage/common/storage-use-azurite.md?tabs=npm#install-azurite). While you can also use an actual Azure Storage account, the article assumes you're using this emulator.
49
+
48
50
## 1. Create your Azure OpenAI resources
49
51
50
52
The following steps show how to create an Azure OpenAI data model in the Azure portal.
@@ -101,16 +103,17 @@ To deploy a model, follow these steps:
101
103
102
104
1. After the deployment completes, navigate to the Azure OpenAI resource page in the Azure portal, and select **Click here to view endpoints** under **Essentials**. Copy the **endpoint** URL and the **keys**. Save these values, you need them later.
103
105
104
-
## 3. Update application settings
105
-
106
106
Now that you have the credentials to connect to your model in Azure OpenAI, you need to set these access credentials in application settings.
107
107
108
-
1. In Visual Studio Code, open the code project you created when you completed the [previous article](./create-first-function-vs-code-csharp.md) and add these values to the local.settings.json file:
108
+
## 3. Update application settings
109
+
110
+
1. In Visual Studio Code, open the code project you created when you completed the [previous article](./create-first-function-vs-code-csharp.md), open the local.settings.json file in the project root folder, and update the `AzureWebJobsStorage` setting to `UseDevelopmentStorage=true`. You can skip this step if the `AzureWebJobsStorage` setting in *local.settings.json* is set to the connection string for an existing Azure Storage account instead of `UseDevelopmentStorage=true`.
109
111
112
+
1. In the local.settings.json file, add these settings values:
110
113
111
114
+**`AZURE_OPENAI_ENDPOINT`**: required by the binding extension. Set this value to the endpoint of the Azure OpenAI resource you created earlier.
112
115
+**`AZURE_OPENAI_KEY`**: required by the binding extension. Set this value to the key for the Azure OpenAI resource.
113
-
+**`CHAT_MODEL_DEPLOYMENT_NAME`**: used to define the input binding. Set this value to `gpt-3.5-turbo`, unless you used a different name for your model deployment.
116
+
+**`CHAT_MODEL_DEPLOYMENT_NAME`**: used to define the input binding. Set this value to the name you chose for your model deployment.
114
117
115
118
1. Save the file. When you deploy to Azure, you must also add these settings to your function app.
116
119
@@ -196,24 +199,24 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
@@ -249,10 +252,13 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
249
252
250
253
## 6. Run the function
251
254
252
-
<!--- 1. Install and start Azurite for local development storage. For instructions on how to work with Azurite: https://learn.microsoft.com/azure/storage/common/storage-use-azurite
253
-
-->
255
+
1. In a Terminal window, run the following command to start the Azurite storage emulator in a separate process:
256
+
257
+
```cmd
258
+
start azurite
259
+
```
254
260
255
-
1. As in the previous article, press <kbd>F5</kbd> to start the function app project and Core Tools.
261
+
1. Press <kbd>F5</kbd> to start the function app project and Core Tools in debug mode.
256
262
257
263
1. With the Core Tools running, send a GET request to the `whois` endpoint function, with a name in the path, like this URL:
258
264
@@ -272,7 +278,7 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
272
278
## 9. Deploy to Azure
273
279
-->
274
280
275
-
## Clean up resources
281
+
## 7. Clean up resources
276
282
277
283
InAzure, *resources*refertofunctionapps, functions, storageaccounts, andsoforth. They're grouped into *resource groups*, and you can delete everything in a group by deleting the group.
0 commit comments