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-app-configuration/howto-chat-completion-config.md
+72Lines changed: 72 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,79 @@ In this section, you will create a chat completion configuration in Azure Portal
50
50
1. In your Azure OpenAI resource, from the **Resource Management** menu, select **Keys and Endpoint** section and copy your Azure OpenAI resource endpoint. It should follow the format: `https://<open-ai-resource-name>.openai.azure.com`.
description: Learn how to create chat completion configuration in Azure App Configuration.
57
+
ms.service: azure-app-configuration
58
+
author: mgichohi
59
+
ms.author: mgichohi
60
+
ms.topic: how-to
61
+
ms.date: 04/20/2025
62
+
ms.collection: ce-skilling-ai-copilot
63
+
---
64
+
65
+
# Chat Completion configuration in Azure App Configuration
66
+
67
+
Chat completion is an AI capability that enables models to generate conversational responses based on a series of messages. Unlike simple text completion, chat completion maintains context across multiple exchanges, simulating a natural conversation. With chat completion configuration, you can define and manage how AI models respond within your application. A typical configuration includes model selection, system and user prompts, and model-specific settings such as temperature or token limits.
68
+
69
+
## Prerequisites
70
+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free)
71
+
- An App Configuration store. [Create a store](./quickstart-azure-app-configuration-create.md#create-an-app-configuration-store).
72
+
73
+
> [!NOTE]
74
+
> This tutorial demonstrates how to use chat completion configuration with an Azure OpenAI model. However, the chat completion configuration demonstrated in the tutorial can be applied to any AI model you choose to work with in your application.
75
+
>
76
+
77
+
## Create a chat completion configuration
78
+
79
+
In this section, you will create a chat completion configuration in Azure Portal using the GPT-4o model as an example.
80
+
81
+
1. In Azure portal, navigate to your App configuration store. From the **Operations** menu, select **Configuration explorer** > **Create**. Then select **AI configuration**.
82
+
83
+
1. Specify the following values:
84
+
-**Key**: Type **ChatLLM:Model**.
85
+
-**Label**: Leave this value blank.
86
+
-**Model**: Select **gpt-4o**.
87
+
88
+
> [!div class="mx-imgBorder"]
89
+
> 
90
+
91
+
1. Leave the rest of the values as default then select **Apply**.
92
+
93
+
## Create an Azure OpenAI resource
94
+
95
+
1. Follow the [Get started with Azure OpenAI Service](/azure/ai-services/openai/overview#get-started-with-azure-openai-service) to create and deploy an Azure OpenAI service resource with following settings:
96
+
97
+
| Field | value |
98
+
|-----------------|---------|
99
+
| Select a model | gpt-4o |
100
+
| Deployment name | gpt-4o |
101
+
102
+
1. In your Azure OpenAI resource, from the **Resource Management** menu, select **Keys and Endpoint** section and copy your Azure OpenAI resource endpoint. It should follow the format: `https://<open-ai-resource-name>.openai.azure.com`.
1. Navigate to your App Configuration store and add the following key-value. Leave **Label** and **Content Type** with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to [Create a key-value](./quickstart-azure-app-configuration-create.md#create-a-key-value).
|_ChatLLM:Endpoint_|_Paste the model endpoint you copied in the previous step_|
111
+
112
+
> [!TIP]
113
+
> To store your model API key securely, consider storing it as a Key Vault reference.
114
+
> - In your Azure OpenAI resource, go to the **Keys and Endpoint** section and copy your API key.
115
+
> - In your App Configuration store, add a new Key Vault reference with the **Key** set to `ChatLLM:ApiKey` and the **Value** set as a Key Vault reference.
116
+
> - For step-by-step guidance, see [Add a Key Vault reference to App Configuration](./use-key-vault-references-dotnet-core.md#add-a-key-vault-reference-to-app-configuration).
117
+
118
+
1. Continue to the following instructions to implement the chat completion configuration into your application for the language or platform you are using.
1. Navigate to your App Configuration store and add the following key-value. Leave **Label** and **Content Type** with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to [Create a key-value](./quickstart-azure-app-configuration-create.md#create-a-key-value).
// Load all keys that start with `ChatLLM:` and have no label.
70
-
.Select("ChatLLM:*")
71
-
// Reload configuration if any selected key-values have changed.
72
-
// Use the default refresh interval of 30 seconds. It can be overridden via AzureAppConfigurationRefreshOptions.SetRefreshInterval.
73
-
.ConfigureRefresh(refresh =>
74
-
{
75
-
refresh.RegisterAll();
76
-
});
69
+
// Load all keys that start with `ChatLLM:` and have no label.
70
+
.Select("ChatLLM:*")
71
+
// Reload configuration if any selected key-values have changed.
72
+
// Use the default refresh interval of 30 seconds. It can be overridden via AzureAppConfigurationRefreshOptions.SetRefreshInterval.
73
+
.ConfigureRefresh(refresh =>
74
+
{
75
+
refresh.RegisterAll();
76
+
});
77
77
78
78
_refresher = options.GetRefresher();
79
79
}).Build();
80
80
```
81
81
82
82
1. Create an instance of the `AzureOpenAIClient` to connect to your Azure OpenAI resource. You can use either Microsoft Entra ID or API key for authentication.
83
83
84
-
To access your Azure OpenAI resource with Microsoft Entra ID, you use `DefaultAzureCredential`. Assign the [Cognitive Services OpenAI User](../role-based-access-control/built-in-roles/ai-machine-learning.md#cognitive-services-openai-user) role to the identity represented by `DefaultAzureCredential`. For detailed steps, refer to the [Role-based access control for Azure OpenAI service](/azure/ai-services/openai/how-to/role-based-access-control) guide. Be sure to allow sufficient time for the permission to propagate before running your application.
84
+
To access your Azure OpenAI resource with Microsoft Entra ID, you use `DefaultAzureCredential`. Assign the **Cognitive Services OpenAI User** role to the identity represented by `DefaultAzureCredential`. For detailed steps, refer to the [Role-based access control for Azure OpenAI service](/azure/ai-services/openai/how-to/role-based-access-control) guide. Be sure to allow sufficient time for the permission to propagate before running your application.
85
85
86
86
```csharp
87
87
// Initialize the AzureOpenAIClient
@@ -241,9 +241,9 @@ In this guide, you build an AI chat application and iterate on the prompt using
241
241
// Reload configuration if any selected key-values have changed.
242
242
// Use the default refresh interval of 30 seconds. It can be overridden via AzureAppConfigurationRefreshOptions.SetRefreshInterval
0 commit comments