Skip to content

Commit e93784c

Browse files
committed
before post-Build merge from main
1 parent 7b6f2dd commit e93784c

File tree

2 files changed

+63
-62
lines changed

2 files changed

+63
-62
lines changed

articles/azure-functions/create-first-function-cli-csharp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ To learn more, see [Azure Functions HTTP triggers and bindings](./functions-bind
166166
167167
This command creates a function app running in your specified language runtime on Linux in the [Flex Consumption Plan](flex-consumption-plan.md), which is free for the amount of usage you incur here. The command also creates an associated Azure Application Insights instance in the same resource group, with which you can monitor your function app and view logs. For more information, see [Monitor Azure Functions](functions-monitoring.md). The instance incurs no costs until you activate it.
168168
169-
8. Add your user-assigned managed identity to the [Monitoring Metrics Publisher](../role-based-access-control/built-in-roles/monitor#monitoring-metrics-publisher) role in your Application Insights instance:
169+
8. Add your user-assigned managed identity to the [Monitoring Metrics Publisher](../role-based-access-control/built-in-roles/monitor.md#monitoring-metrics-publisher) role in your Application Insights instance:
170170
171171
:::code language="azurecli" source="~/azure_cli_scripts/azure-functions/create-function-app-flex-plan-identities/create-function-app-flex-plan-identities.md" range="42-44":::
172172

articles/azure-functions/functions-add-openai-text-completion.md

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,39 @@ zone_pivot_groups: programming-languages-set-functions
1313

1414
# Tutorial: Add Azure OpenAI text completion hints to your functions in Visual Studio Code
1515

16-
This article shows you how to use Visual Studio Code to add an HTTP endpoint to the function app you created in the previous quickstart article. When triggered, this new HTTP endpoint uses an [Azure OpenAI text completion input binding](functions-bindings-openai-textcompletion-input.md) to get text completion hints from your data model.
16+
This article shows you how to add an HTTP endpoint to the function app you created in the previous quickstart article. When triggered, this new HTTP endpoint uses an [Azure OpenAI text completion input binding](functions-bindings-openai-textcompletion-input.md) to get text completion hints from your data model.
1717

1818
During this tutorial, you learn how to accomplish these tasks:
1919

2020
> [!div class="checklist"]
2121
> * Create resources in Azure OpenAI.
22+
> * Enable managed identity access to your OpenAI resource.
2223
> * Deploy a model in OpenAI the resource.
2324
> * Set access permissions to the model resource.
2425
> * Enable your function app to connect to OpenAI.
2526
> * Add OpenAI bindings to your HTTP triggered function.
2627
27-
## 1. Check prerequisites
28-
:::zone pivot="programming-language-csharp"
29-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-csharp.md).
30-
:::zone-end
31-
:::zone pivot="programming-language-java"
32-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-java.md).
33-
:::zone-end
34-
:::zone pivot="programming-language-javascript"
35-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-node.md).
36-
:::zone-end
37-
:::zone pivot="programming-language-typescript"
38-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-typescript.md).
39-
:::zone-end
40-
:::zone pivot="programming-language-python"
41-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-python.md).
42-
:::zone-end
43-
:::zone pivot="programming-language-powershell"
44-
* Complete the steps in [part 1 of the Visual Studio Code quickstart](create-first-function-vs-code-powershell.md).
45-
:::zone-end
46-
* 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.
47-
:::zone pivot="programming-language-csharp"
48-
* Install [.NET Core CLI tools](/dotnet/core/tools/?tabs=netcore2x).
49-
:::zone-end
50-
* 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.
51-
52-
## 2. Create your Azure OpenAI resources
28+
## Prerequisites
29+
30+
- Complete the steps in [Quickstart: Create and deploy functions to Azure Functions using the Azure Developer CLI](create-first-function-azure-developer-cli.md).
31+
32+
- 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.
33+
34+
## Create your Azure OpenAI resources
5335

54-
The following steps show how to create an Azure OpenAI data model in the Azure portal.
36+
Use these steps to create an Azure OpenAI data model:
5537

56-
1. Sign in with your Azure subscription in the [Azure portal](https://portal.azure.com).
38+
### [Azure portal](#tab/azure-portal)
5739

58-
1. Select **Create a resource** and search for the **Azure OpenAI**. When you locate the service, select **Create**.
40+
1. In the Azure portal, select **Create a resource** and search for the **Azure OpenAI**. When you locate the service, select **Create**.
5941

6042
1. On the **Create Azure OpenAI** page, provide the following information for the fields on the **Basics** tab:
6143

6244
| Field | Description |
6345
|---|---|
6446
| **Subscription** | Your subscription, which has been onboarded to use Azure OpenAI. |
65-
| **Resource group** | The resource group you created for the function app in the previous article. You can find this resource group name by right-clicking the function app in the Azure Resources browser, selecting properties, and then searching for the `resourceGroup` setting in the returned JSON resource file. |
66-
| **Region** | Ideally, the same location as the function app. |
47+
| **Resource group** | Use the same same resource group as your existing function app. |
48+
| **Region** | Ideally, use the same same region where your existing function app is hosted. |
6749
| **Name** | A descriptive name for your Azure OpenAI Service resource, such as _mySampleOpenAI_. |
6850
| **Pricing Tier** | The pricing tier for the resource. Currently, only the Standard tier is available for the Azure OpenAI Service. For more info on pricing visit the [Azure OpenAI pricing page](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/) |
6951

@@ -77,54 +59,78 @@ The following steps show how to create an Azure OpenAI data model in the Azure p
7759

7860
The Azure portal displays a notification when the new resource is available. Select **Go to resource** in the notification or search for your new Azure OpenAI resource by name.
7961

80-
1. In the Azure OpenAI resource page for your new resource, select **Click here to view endpoints** under **Essentials** > **Endpoints**. Copy the **endpoint** URL and the **keys**. Save these values, you need them later.
62+
1. In the Azure OpenAI resource page for your new resource, select **Click here to view endpoints** under **Essentials** > **Endpoints**.
8163

82-
Now that you have the credentials to connect to your model in Azure OpenAI, you need to set these access credentials in application settings.
64+
1. Copy the **endpoint** URL, which you need to use later.
8365

84-
## 3. Deploy a model
66+
### [Azure CLI](#tab/azure-cli)
67+
68+
1. Use the command to
69+
70+
---
71+
72+
Next, you grant access to the user-assigned managed identity to be able to connect to your Azure OpenAI resource.
73+
74+
## 4. Grant user access to Azure OpenAI
75+
76+
Use these steps to grant access in your new Azure OpenAI resource both to the user-assigned manage identity associated with your app and to your Azure account.
77+
78+
1. In your Azure OpenAI resource, select **Access control (IAM)** on the left pane.
79+
80+
1. Select **Add** > **Add role assignment**.
81+
82+
1. On the **Role** tab on the next screen, select **Cognitive Services OpenAI User** and then **Next**.
83+
84+
1. On the **Members** tab, select **Assign access to** > **Managed identity** then **Select members**.
85+
86+
1. In the **Select managed identities** pane, select **Managed identity** > **User assigned managed identity**.
87+
88+
1. Choose your user-assigned managed identity from the list and then **Select** > **Review + assign**.
89+
90+
1. On the **Review + assign** tab, select **Review + assign** to assign the role.
91+
92+
## 5. Deploy a model
8593

8694
Now you can deploy a model. You can select from one of several available models in Azure OpenAI Studio.
8795

8896
To deploy a model, follow these steps:
8997

9098
1. Sign in to [Azure OpenAI Studio](https://oai.azure.com).
9199

92-
1. Choose the subscription and the Azure OpenAI resource you created, and select **Use resource**.
100+
1. In the correct **Subscription** and **Directory**, select the name of the Azure OpenAI resource you created, and select **Use resource**.
93101

94-
1. Under **Management** select **Deployments**.
102+
1. Under **Shared resources** select **Deployments**.
95103

96-
1. Select **Create new deployment** and configure the following fields:
104+
1. Select **Deploy model** > **Deploy base model**, choose your base model from the list, such as `gpt-4o`, and select **Confirm**.
97105

98-
| Field | Description |
99-
|---|---|
100-
| **Deployment name** | Choose a name carefully. The deployment name is used in your code to call the model by using the client libraries and the REST APIs, so you must save for use later on. |
101-
| **Select a model** | Model availability varies by region. For a list of available models per region, see [Model summary table and region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability). |
106+
Model availability varies by region. For a list of available models per region, see [Model summary table and region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability).
102107

103-
> [!IMPORTANT]
104-
> When you access the model via the API, you need to refer to the deployment name rather than the underlying model name in API calls, which is one of the key differences between OpenAI and Azure OpenAI. OpenAI only requires the model name. Azure OpenAI always requires deployment name, even when using the model parameter. In our docs, we often have examples where deployment names are represented as identical to model names to help indicate which model works with a particular API endpoint. Ultimately your deployment names can follow whatever naming convention is best for your use case.
108+
1. Confirm the **Deployment name** for your model deployment and select **Deploy**.
105109

106-
1. Accept the default values for the rest of the setting and select **Create**.
110+
Choose a deployment name carefully. The deployment name is used in your code to call the model by using the client libraries and the REST APIs, so you must save it for use later on.
107111

108-
The deployments table shows a new entry that corresponds to your newly created model.
112+
> [!IMPORTANT]
113+
> When you access the model via the API, you need to refer to the deployment name rather than the underlying model name in API calls, which is one of the key differences between OpenAI and Azure OpenAI. OpenAI only requires the model name. Azure OpenAI always requires deployment name, even when using the model parameter. In our docs, we often have examples where deployment names are represented as identical to model names to help indicate which model works with a particular API endpoint. Ultimately your deployment names can follow whatever naming convention is best for your use case.
109114
110115
You now have everything you need to add Azure OpenAI-based text completion to your function app.
111116

112-
## 4. Update application settings
117+
## 6. Update application settings
113118

114119
1. In Visual Studio Code, open the local code project you created when you completed the [previous article](./create-first-function-vs-code-csharp.md).
115120

116121
1. In the local.settings.json file in the project root folder, 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`.
117122

118123
1. In the local.settings.json file, add these settings values:
119124

120-
+ **`AZURE_OPENAI_ENDPOINT`**: required by the binding extension. Set this value to the endpoint of the Azure OpenAI resource you created earlier.
121-
+ **`AZURE_OPENAI_KEY`**: required by the binding extension. Set this value to the key for the Azure OpenAI resource.
122-
+ **`CHAT_MODEL_DEPLOYMENT_NAME`**: used to define the input binding. Set this value to the name you chose for your model deployment.
125+
+ **`AzureOpenAI__endpoint`**: required by the binding extension. Set this value to the endpoint of the Azure OpenAI resource you created earlier.
126+
+ **`"AzureOpenAI__tenantId"`**: required when running locally to connect to Azure OpenAI with the user-assigned managed identity. Set this value to the **Tenant ID** value you saved earlier.
127+
+ **`AzureOpenAI__clientId`**: required when running locally and in Azure. Set this value to the **Client ID** value you saved earlier.
128+
+ **`CHAT_MODEL_DEPLOYMENT_NAME`**: used by input binding settings. Set this value to the name you chose for your model deployment.
123129

124130
1. Save the file. When you deploy to Azure, you must also add these settings to your function app.
125131

126132
:::zone pivot="programming-language-csharp"
127-
## 5. Register binding extensions
133+
## 7. Register binding extensions
128134

129135
Because you're using an Azure OpenAI output binding, you must have the corresponding bindings extension installed before you run the project.
130136

@@ -136,7 +142,7 @@ dotnet add package Microsoft.Azure.Functions.Worker.Extensions.OpenAI --prerelea
136142
:::zone-end
137143
:::zone pivot="programming-language-java,programming-language-javascript,programming-language-typescript,programming-language-python,programming-language-powershell"
138144
<!---NOTE: Update this after preview to `## Verify the extension bundle`-->
139-
## 5. Update the extension bundle
145+
## 7. Update the extension bundle
140146

141147
To access the preview Azure OpenAI bindings, you must use a preview version of the extension bundle that contains this extension.
142148

@@ -151,7 +157,7 @@ Replace the `extensionBundle` setting in your current `host.json` file with this
151157
:::zone-end
152158
Now, you can use the Azure OpenAI output binding in your project.
153159

154-
## 6. Return text completion from the model
160+
## 8. Return text completion from the model
155161

156162
The code you add creates a `whois` HTTP function endpoint in your existing project. In this function, data passed in a URL `name` parameter of a GET request is used to dynamically create a completion prompt. This dynamic prompt is bound to a text completion input binding, which returns a response from the model based on the prompt. The completion from the model is returned in the HTTP response.
157163
:::zone pivot="programming-language-csharp"
@@ -234,7 +240,7 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
234240

235241
:::zone-end
236242

237-
## 7. Run the function
243+
## 9. Run the function
238244

239245
1. In Visual Studio Code, Press F1 and in the command palette type `Azurite: Start` and press Enter to start the Azurite storage emulator.
240246

@@ -250,15 +256,10 @@ The code you add creates a `whois` HTTP function endpoint in your existing proje
250256

251257
1. After a response is returned, press <kbd>Ctrl + C</kbd> to stop Core Tools.
252258

253-
<!-- enable managed identities
254-
## 8. Set access permissions
255-
{{move this info into the main article}}
256-
[create Azure OpenAI resources and to deploy models](../ai-services/openai/how-to/role-based-access-control.md).
259+
## 10. Deploy to Azure
257260

258-
## 9. Deploy to Azure
259-
-->
260261

261-
## 8. Clean up resources
262+
## 11. Clean up resources
262263

263264
In Azure, *resources* refer to function apps, functions, storage accounts, and so forth. They're grouped into *resource groups*, and you can delete everything in a group by deleting the group.
264265

0 commit comments

Comments
 (0)