Skip to content

Commit 778037a

Browse files
Merge pull request #267104 from aahill/app-support
updating evironment vars
2 parents 1fbe99b + 657ce56 commit 778037a

11 files changed

+102
-100
lines changed

articles/ai-services/openai/concepts/use-your-data.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ You can send a streaming request using the `stream` parameter, allowing data to
361361
{
362362
"type": "AzureCognitiveSearch",
363363
"parameters": {
364-
"endpoint": "'$SearchEndpoint'",
365-
"key": "'$SearchKey'",
366-
"indexName": "'$SearchIndex'"
364+
"endpoint": "'$AZURE_AI_SEARCH_ENDPOINT'",
365+
"key": "'$AZURE_AI_SEARCH_API_KEY'",
366+
"indexName": "'$AZURE_AI_SEARCH_INDEX'"
367367
}
368368
}
369369
],
@@ -386,9 +386,9 @@ When you chat with a model, providing a history of the chat will help the model
386386
{
387387
"type": "AzureCognitiveSearch",
388388
"parameters": {
389-
"endpoint": "'$SearchEndpoint'",
390-
"key": "'$SearchKey'",
391-
"indexName": "'$SearchIndex'"
389+
"endpoint": "'$AZURE_AI_SEARCH_ENDPOINT'",
390+
"key": "'$AZURE_AI_SEARCH_API_KEY'",
391+
"indexName": "'$AZURE_AI_SEARCH_INDEX'"
392392
}
393393
}
394394
],

articles/ai-services/openai/how-to/migration.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: How to migrate to OpenAI Python v1.x
33
titleSuffix: Azure OpenAI Service
4-
description: Learn about migrating to the latest release of the OpenAI Python library with Azure OpenAI
4+
description: Learn about migrating to the latest release of the OpenAI Python library with Azure OpenAI.
55
author: mrbullwinkle
66
ms.author: mbullwin
77
ms.service: azure-ai-openai
88
ms.custom: devx-track-python
99
ms.topic: how-to
10-
ms.date: 11/15/2023
10+
ms.date: 02/26/2024
1111
manager: nitinme
1212
---
1313

@@ -17,7 +17,7 @@ OpenAI has just released a new version of the [OpenAI Python API library](https:
1717

1818
## Updates
1919

20-
- This is a completely new version of the OpenAI Python API library.
20+
- This is a new version of the OpenAI Python API library.
2121
- Starting on November 6, 2023 `pip install openai` and `pip install openai --upgrade` will install `version 1.x` of the OpenAI Python library.
2222
- Upgrading from `version 0.28.1` to `version 1.x` is a breaking change, you'll need to test and update your code.
2323
- Auto-retry with backoff if there's an error
@@ -259,7 +259,7 @@ print(completion.model_dump_json(indent=2))
259259

260260
## Use your data
261261

262-
For the full configuration steps that are required to make these code examples work, please consult the [use your data quickstart](../use-your-data-quickstart.md).
262+
For the full configuration steps that are required to make these code examples work, consult the [use your data quickstart](../use-your-data-quickstart.md).
263263
# [OpenAI Python 0.28.1](#tab/python)
264264

265265
```python
@@ -270,10 +270,10 @@ import requests
270270

271271
dotenv.load_dotenv()
272272

273-
openai.api_base = os.environ.get("AOAIEndpoint")
273+
openai.api_base = os.environ.get("AZURE_OPENAI_ENDPOINT")
274274
openai.api_version = "2023-08-01-preview"
275275
openai.api_type = 'azure'
276-
openai.api_key = os.environ.get("AOAIKey")
276+
openai.api_key = os.environ.get("AZURE_OPENAI_API_KEY")
277277

278278
def setup_byod(deployment_id: str) -> None:
279279
"""Sets up the OpenAI Python SDK to use your own data for the chat endpoint.
@@ -299,19 +299,19 @@ def setup_byod(deployment_id: str) -> None:
299299

300300
openai.requestssession = session
301301

302-
aoai_deployment_id = os.environ.get("AOAIDeploymentId")
302+
aoai_deployment_id = os.environ.get("AZURE_OPEN_AI_DEPLOYMENT_ID")
303303
setup_byod(aoai_deployment_id)
304304

305305
completion = openai.ChatCompletion.create(
306306
messages=[{"role": "user", "content": "What are the differences between Azure Machine Learning and Azure AI services?"}],
307-
deployment_id=os.environ.get("AOAIDeploymentId"),
307+
deployment_id=os.environ.get("AZURE_OPEN_AI_DEPLOYMENT_ID"),
308308
dataSources=[ # camelCase is intentional, as this is the format the API expects
309309
{
310310
"type": "AzureCognitiveSearch",
311311
"parameters": {
312-
"endpoint": os.environ.get("SearchEndpoint"),
313-
"key": os.environ.get("SearchKey"),
314-
"indexName": os.environ.get("SearchIndex"),
312+
"endpoint": os.environ.get("AZURE_AI_SEARCH_ENDPOINT"),
313+
"key": os.environ.get("AZURE_AI_SEARCH_API_KEY"),
314+
"indexName": os.environ.get("AZURE_AI_SEARCH_INDEX"),
315315
}
316316
}
317317
]
@@ -328,9 +328,9 @@ import dotenv
328328

329329
dotenv.load_dotenv()
330330

331-
endpoint = os.environ.get("AOAIEndpoint")
332-
api_key = os.environ.get("AOAIKey")
333-
deployment = os.environ.get("AOAIDeploymentId")
331+
endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT")
332+
api_key = os.environ.get("AZURE_OPENAI_API_KEY")
333+
deployment = os.environ.get("AZURE_OPEN_AI_DEPLOYMENT_ID")
334334

335335
client = openai.AzureOpenAI(
336336
base_url=f"{endpoint}/openai/deployments/{deployment}/extensions",
@@ -351,9 +351,9 @@ completion = client.chat.completions.create(
351351
{
352352
"type": "AzureCognitiveSearch",
353353
"parameters": {
354-
"endpoint": os.environ["SearchEndpoint"],
355-
"key": os.environ["SearchKey"],
356-
"indexName": os.environ["SearchIndex"]
354+
"endpoint": os.environ["AZURE_AI_SEARCH_ENDPOINT"],
355+
"key": os.environ["AZURE_AI_SEARCH_API_KEY"],
356+
"indexName": os.environ["AZURE_AI_SEARCH_INDEX"]
357357
}
358358
}
359359
]

articles/ai-services/openai/how-to/use-web-app.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: azure-ai-openai
77
ms.topic: how-to
88
author: aahill
99
ms.author: aahi
10-
ms.date: 02/09/2024
10+
ms.date: 02/23/2024
1111
recommendations: false
1212
---
1313

@@ -43,6 +43,8 @@ When customizing the app, we recommend:
4343

4444
- When you rotate API keys for your Azure OpenAI or Azure AI Search resource, be sure to update the app settings for each of your deployed apps to use the new keys.
4545

46+
Sample source code for Azure OpenAI On Your Data web app is available on [GitHub](https://github.com/microsoft/sample-app-aoai-chatGPT). Source code is provided "as is" and as a sample only. Customers are responsible for all customization and implementation of their web apps using Azure OpenAI On Your Data.
47+
4648
### Updating the web app
4749

4850
We recommend pulling changes from the `main` branch for the web app's source code frequently to ensure you have the latest bug fixes, API version, and improvements.

articles/ai-services/openai/how-to/use-your-data-securely.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ When using the API, pass the `filter` parameter in each API request. For example
9090
{
9191
"type": "AzureCognitiveSearch",
9292
"parameters": {
93-
"endpoint": "'$SearchEndpoint'",
94-
"key": "'$SearchKey'",
95-
"indexName": "'$SearchIndex'",
93+
"endpoint": "'$AZURE_AI_SEARCH_ENDPOINT'",
94+
"key": "'$AZURE_AI_SEARCH_API_KEY'",
95+
"indexName": "'$AZURE_AI_SEARCH_INDEX'",
9696
"filter": "my_group_ids/any(g:search.in(g, 'group_id1, group_id2'))"
9797
}
9898
}

articles/ai-services/openai/includes/use-your-data-common-variables.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,82 +14,82 @@ To successfully make a call against Azure OpenAI, you need the following variabl
1414

1515
|Variable name | Value |
1616
|--------------------------|-------------|
17-
| `AOAIEndpoint` | This value can be found in the **Keys & Endpoint** section when examining your Azure OpenAI resource from the Azure portal. Alternatively, you can find the value in **Azure AI studio** > **Chat playground** > **Code view**. An example endpoint is: `https://my-resoruce.openai.azure.com`.|
18-
| `AOAIKey` | This value can be found in **Resource management** > **Keys & Endpoint** section when examining your Azure OpenAI resource from the Azure portal. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption. |
19-
| `AOAIDeploymentId` | This value corresponds to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure AI studio.|
20-
| `SearchEndpoint` | This value can be found in the **Overview** section when examining your Azure AI Search resource from the Azure portal. |
21-
| `SearchKey` | This value can be found in the **Settings** > **Keys** section when examining your Azure AI Search resource from the Azure portal. You can use either the primary admin key or secondary admin key. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption. |
22-
| `SearchIndex` | This value corresponds to the name of the index you created to store your data. You can find it in the **Overview** section when examining your Azure AI Search resource from the Azure portal. |
17+
| `AZURE_OPENAI_ENDPOINT` | This value can be found in the **Keys & Endpoint** section when examining your Azure OpenAI resource from the Azure portal. Alternatively, you can find the value in **Azure AI studio** > **Chat playground** > **Code view**. An example endpoint is: `https://my-resoruce.openai.azure.com`.|
18+
| `AZURE_OPENAI_API_KEY` | This value can be found in **Resource management** > **Keys & Endpoint** section when examining your Azure OpenAI resource from the Azure portal. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption. |
19+
| `AZURE_OPEN_AI_DEPLOYMENT_ID` | This value corresponds to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure AI studio.|
20+
| `AZURE_AI_SEARCH_ENDPOINT` | This value can be found in the **Overview** section when examining your Azure AI Search resource from the Azure portal. |
21+
| `AZURE_AI_SEARCH_API_KEY` | This value can be found in the **Settings** > **Keys** section when examining your Azure AI Search resource from the Azure portal. You can use either the primary admin key or secondary admin key. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption. |
22+
| `AZURE_AI_SEARCH_INDEX` | This value corresponds to the name of the index you created to store your data. You can find it in the **Overview** section when examining your Azure AI Search resource from the Azure portal. |
2323

2424
### Environment variables
2525

2626
# [Command Line](#tab/command-line)
2727

2828
```CMD
29-
setx AOAIEndpoint REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE
29+
setx AZURE_OPENAI_ENDPOINT REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE
3030
```
3131
```CMD
32-
setx AOAIKey REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE
32+
setx AZURE_OPENAI_API_KEY REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE
3333
```
3434
```CMD
35-
setx AOAIDeploymentId REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE
35+
setx AZURE_OPENAI_DEPLOYMENT_ID REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE
3636
```
3737
```CMD
38-
setx SearchEndpoint REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE
38+
setx AZURE_AI_SEARCH_ENDPOINT REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE
3939
```
4040
```CMD
41-
setx SearchKey REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE
41+
setx AZURE_AI_SEARCH_API_KEY REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE
4242
```
4343
```CMD
44-
setx SearchIndex REPLACE_WITH_YOUR_INDEX_NAME_HERE
44+
setx AZURE_AI_SEARCH_INDEX REPLACE_WITH_YOUR_INDEX_NAME_HERE
4545
```
4646

4747

4848
# [PowerShell](#tab/powershell)
4949

5050
```powershell
51-
[System.Environment]::SetEnvironmentVariable('AOAIEndpoint', 'REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE', 'User')
51+
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_ENDPOINT', 'REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE', 'User')
5252
```
5353

5454
```powershell
55-
[System.Environment]::SetEnvironmentVariable('AOAIKey', 'REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE', 'User')
55+
[System.Environment]::SetEnvironmentVariable('AZURE_OPENAI_API_KEY', 'REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE', 'User')
5656
```
5757

5858
```powershell
59-
[System.Environment]::SetEnvironmentVariable('AOAIDeploymentId', 'REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE', 'User')
59+
[System.Environment]::SetEnvironmentVariable('AZURE_OPEN_AI_DEPLOYMENT_ID', 'REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE', 'User')
6060
```
6161

6262
```powershell
63-
[System.Environment]::SetEnvironmentVariable('SearchEndpoint', 'REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE', 'User')
63+
[System.Environment]::SetEnvironmentVariable('AZURE_AI_SEARCH_ENDPOINT', 'REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE', 'User')
6464
```
6565

6666
```powershell
67-
[System.Environment]::SetEnvironmentVariable('SearchKey', 'REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE', 'User')
67+
[System.Environment]::SetEnvironmentVariable('AZURE_AI_SEARCH_API_KEY', 'REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE', 'User')
6868
```
6969

7070
```powershell
71-
[System.Environment]::SetEnvironmentVariable('SearchIndex', 'REPLACE_WITH_YOUR_INDEX_NAME_HERE', 'User')
71+
[System.Environment]::SetEnvironmentVariable('AZURE_AI_SEARCH_INDEX', 'REPLACE_WITH_YOUR_INDEX_NAME_HERE', 'User')
7272
```
7373

7474
# [Bash](#tab/bash)
7575

7676
```Bash
77-
export AOAIEndpoint=REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE
77+
export AZURE_OPENAI_ENDPOINT=REPLACE_WITH_YOUR_AOAI_ENDPOINT_VALUE_HERE
7878
```
7979
```Bash
80-
export AOAIKey=REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE
80+
export AZURE_OPENAI_API_KEY=REPLACE_WITH_YOUR_AOAI_KEY_VALUE_HERE
8181
```
8282
```Bash
83-
export AOAIDeploymentId=REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE
83+
export AZURE_OPEN_AI_DEPLOYMENT_ID=REPLACE_WITH_YOUR_AOAI_DEPLOYMENT_VALUE_HERE
8484
```
8585
```Bash
86-
export SearchEndpoint=REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE
86+
export AZURE_AI_SEARCH_ENDPOINT=REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_VALUE_HERE
8787
```
8888
```Bash
89-
export SearchKey=REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE
89+
export AZURE_AI_SEARCH_API_KEY=REPLACE_WITH_YOUR_AZURE_SEARCH_RESOURCE_KEY_VALUE_HERE
9090
```
9191
```Bash
92-
export SearchIndex=REPLACE_WITH_YOUR_INDEX_NAME_HERE
92+
export AZURE_AI_SEARCH_INDEX=REPLACE_WITH_YOUR_INDEX_NAME_HERE
9393
```
9494

9595
---

articles/ai-services/openai/includes/use-your-data-dotnet.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ using Azure.AI.OpenAI;
2222
using System.Text.Json;
2323
using static System.Environment;
2424

25-
string azureOpenAIEndpoint = GetEnvironmentVariable("AOAIEndpoint");
26-
string azureOpenAIKey = GetEnvironmentVariable("AOAIKey");
27-
string searchEndpoint = GetEnvironmentVariable("SearchEndpoint");
28-
string searchKey = GetEnvironmentVariable("SearchKey");
29-
string searchIndex = GetEnvironmentVariable("SearchIndex");
30-
string deploymentName = GetEnvironmentVariable("AOAIDeploymentId");
25+
string azureOpenAIEndpoint = GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
26+
string azureOpenAIKey = GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
27+
string searchEndpoint = GetEnvironmentVariable("AZURE_AI_SEARCH_ENDPOINT");
28+
string searchKey = GetEnvironmentVariable("AZURE_AI_SEARCH_API_KEY");
29+
string searchIndex = GetEnvironmentVariable("AZURE_AI_SEARCH_INDEX");
30+
string deploymentName = GetEnvironmentVariable("AZURE_OPEN_AI_DEPLOYMENT_ID");
3131

3232

3333
var client = new OpenAIClient(new Uri(azureOpenAIEndpoint), new AzureKeyCredential(azureOpenAIKey));
@@ -128,12 +128,12 @@ using Azure.AI.OpenAI;
128128
using System.Text.Json;
129129
using static System.Environment;
130130

131-
string azureOpenAIEndpoint = GetEnvironmentVariable("AOAIEndpoint");
132-
string azureOpenAIKey = GetEnvironmentVariable("AOAIKey");
133-
string searchEndpoint = GetEnvironmentVariable("SearchEndpoint");
134-
string searchKey = GetEnvironmentVariable("SearchKey");
135-
string searchIndex = GetEnvironmentVariable("SearchIndex");
136-
string deploymentName = GetEnvironmentVariable("AOAIDeploymentId");
131+
string azureOpenAIEndpoint = GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
132+
string azureOpenAIKey = GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
133+
string searchEndpoint = GetEnvironmentVariable("AZURE_AI_SEARCH_ENDPOINT");
134+
string searchKey = GetEnvironmentVariable("AZURE_AI_SEARCH_API_KEY");
135+
string searchIndex = GetEnvironmentVariable("AZURE_AI_SEARCH_INDEX");
136+
string deploymentName = GetEnvironmentVariable("AZURE_OPEN_AI_DEPLOYMENT_ID");
137137

138138

139139
var client = new OpenAIClient(new Uri(azureOpenAIEndpoint), new AzureKeyCredential(azureOpenAIKey));

articles/ai-services/openai/includes/use-your-data-go.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ ms.date: 08/29/2023
4747
)
4848
4949
func main() {
50-
azureOpenAIKey := os.Getenv("AOAIKey")
51-
modelDeploymentID := os.Getenv("AOAIDeploymentId")
50+
azureOpenAIKey := os.Getenv("AZURE_OPENAI_API_KEY")
51+
modelDeploymentID := os.Getenv("AZURE_OPEN_AI_DEPLOYMENT_ID")
5252
5353
// Ex: "https://<your-azure-openai-host>.openai.azure.com"
54-
azureOpenAIEndpoint := os.Getenv("AOAIEndpoint")
54+
azureOpenAIEndpoint := os.Getenv("AZURE_OPENAI_ENDPOINT")
5555
5656
// Azure AI Search configuration
57-
searchIndex := os.Getenv("SearchIndex")
58-
searchEndpoint := os.Getenv("SearchEndpoint")
59-
searchAPIKey := os.Getenv("SearchKey")
57+
searchIndex := os.Getenv("AZURE_AI_SEARCH_INDEX")
58+
searchEndpoint := os.Getenv("AZURE_AI_SEARCH_ENDPOINT")
59+
searchAPIKey := os.Getenv("AZURE_AI_SEARCH_API_KEY")
6060
6161
if azureOpenAIKey == "" || modelDeploymentID == "" || azureOpenAIEndpoint == "" || searchIndex == "" || searchEndpoint == "" || searchAPIKey == "" {
6262
fmt.Fprintf(os.Stderr, "Skipping example, environment variables missing\n")

articles/ai-services/openai/includes/use-your-data-javascript.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ const { OpenAIClient } = require("@azure/openai");
3838
const { DefaultAzureCredential } = require("@azure/identity")
3939

4040
// Set the Azure and AI Search values from environment variables
41-
const endpoint = process.env["AOAIEndpoint"];
42-
const azureApiKey = process.env["AOAIKey"];
43-
const searchEndpoint = process.env["SearchEndpoint"];
44-
const searchKey = process.env["SearchKey"];
45-
const searchIndex = process.env["SearchIndex"];
46-
const deploymentId = process.env["AOAIDeploymentId"];
41+
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"];
42+
const azureApiKey = process.env["AZURE_OPENAI_API_KEY"];
43+
const searchEndpoint = process.env["AZURE_AI_SEARCH_ENDPOINT"];
44+
const searchKey = process.env["AZURE_AI_SEARCH_API_KEY"];
45+
const searchIndex = process.env["AZURE_AI_SEARCH_INDEX"];
46+
const deploymentId = process.env["AZURE_OPEN_AI_DEPLOYMENT_ID"];
4747

4848
async function main() {
4949
console.log("== Chat Using Your Own Data Sample ==");

0 commit comments

Comments
 (0)