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/ai-services/openai/includes/chatgpt-powershell.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,9 @@ For the recommended keyless authentication with Microsoft Entra ID, you need to:
85
85
return $response
86
86
```
87
87
88
+
> [!IMPORTANT]
89
+
> For production, use a secure way of storing and accessing your credentials like [The PowerShell Secret Management with Azure Key Vault](/powershell/utility-modules/secretmanagement/how-to/using-azure-keyvault). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
90
+
88
91
1. Run the script using PowerShell. In this example, we're using the `-Depth` parameter to ensure that the output isn't truncated.
Copy file name to clipboardExpand all lines: articles/ai-services/openai/includes/dall-e-powershell.md
+57-49Lines changed: 57 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,10 @@
2
2
title: "Quickstart: Generate images with Azure OpenAI Service using PowerShell"
3
3
titleSuffix: Azure OpenAI Service
4
4
description: Learn how to generate images with Azure OpenAI Service by using PowerShell and the endpoint and access keys for your Azure OpenAI resource.
5
-
#services: cognitive-services
6
5
manager: nitinme
7
6
ms.service: azure-ai-openai
8
7
ms.topic: include
9
-
ms.date: 08/29/2023
8
+
ms.date: 3/21/2025
10
9
---
11
10
12
11
Use this guide to get started calling the Azure OpenAI Service image generation APIs with PowerShell.
@@ -21,70 +20,79 @@ Use this guide to get started calling the Azure OpenAI Service image generation
21
20
- An Azure OpenAI resource created in a supported region (see [Region availability](/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability)). For more information, see [Create a resource and deploy a model with Azure OpenAI](../how-to/create-resource.md).
For the recommended keyless authentication with Microsoft Entra ID, you need to:
26
+
- Install the [Azure CLI](/cli/azure/install-azure-cli) used for keyless authentication with Microsoft Entra ID.
27
+
- Assign the `Cognitive Services User` role to your user account. You can assign roles in the Azure portal under **Access control (IAM)** > **Add role assignment**.
1. Create a new PowerShell file named _quickstart.ps1_. Open the new file in your preferred editor or IDE.
35
+
1. For the **recommended** keyless authentication with Microsoft Entra ID, sign in to Azure with the following command:
36
+
37
+
```console
38
+
az login
39
+
```
40
+
41
+
1. Create a new PowerShell file called *quickstart.ps1*. Then open it up in your preferred editor or IDE.
34
42
35
43
1. Replace the contents of _quickstart.ps1_ with the following code. Enter your endpoint URL and key in the appropriate fields. Change the value of `prompt` to your preferred text.
36
44
37
45
```powershell
38
-
# Azure OpenAI metadata variables
39
-
$openai = @{
40
-
api_key= $Env:AZURE_OPENAI_API_KEY
41
-
api_base = $Env:AZURE_OPENAI_ENDPOINT # your endpoint should look like the following https://YOUR_RESOURCE_NAME.openai.azure.com/
42
-
api_version = '2023-06-01-preview' # this may change in the future
43
-
}
44
-
45
-
# Text to describe image
46
-
$prompt = 'A painting of a dog'
47
-
48
-
# Header for authentication
49
-
$headers = [ordered]@{
50
-
'api-key' = $openai.api_key
51
-
}
52
-
53
-
# Adjust these values to fine-tune completions
54
-
$body = [ordered]@{
55
-
prompt = $prompt
56
-
size = '1024x1024'
57
-
n = 1
58
-
} | ConvertTo-Json
59
-
46
+
# Azure OpenAI metadata variables
47
+
$openai = @{
48
+
api_base = $Env:AZURE_OPENAI_ENDPOINT
49
+
api_version = '2023-06-01-preview' # This can change in the future.
50
+
}
51
+
52
+
# Use the recommended keyless authentication via bearer token.
0 commit comments