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
- 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).
24
23
24
+
### Microsoft Entra ID prerequisites
25
25
26
-
## Setup
26
+
For the recommended keyless authentication with Microsoft Entra ID, you need to:
27
+
- Install the [Azure CLI](/cli/azure/install-azure-cli) used for keyless authentication with Microsoft Entra ID.
28
+
- 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**.
In a console window (such as cmd, PowerShell, or Bash), create a new directory for your app, and navigate to it.
87
+
```console
88
+
mvn clean dependency:copy-dependencies
89
+
```
38
90
39
-
```console
40
-
mkdir myapp && cd myapp
41
-
```
91
+
1. For the **recommended** keyless authentication with Microsoft Entra ID, sign in to Azure with the following command:
42
92
43
-
Run the `gradle init` command from your working directory. This command will create essential build files for Gradle, including *build.gradle.kts*, which is used at runtime to create and configure your application.
93
+
```console
94
+
az login
95
+
```
44
96
45
-
```console
46
-
gradle init --type basic
47
-
```
48
97
49
-
When prompted to choose a **DSL**, select **Kotlin**.
The sample code in this quickstart uses Microsoft Entra ID for the recommended keyless authentication. If you prefer to use an API key, you can replace the `DefaultAzureCredential` object with an `AzureKeyCredential` object.
53
105
54
-
This quickstart uses the Gradle dependency manager. You can find the client library and information for other dependency managers on the [Maven Central Repository](https://search.maven.org/artifact/com.microsoft.azure.cognitiveservices/azure-cognitiveservices-computervision).
106
+
#### [Microsoft Entra ID](#tab/keyless)
107
+
108
+
```java
109
+
OpenAIAsyncClient client = new OpenAIClientBuilder()
Locate *build.gradle.kts* and open it with your preferred IDE or text editor. Then copy in the following build configuration. This configuration defines the project as a Java application whose entry point is the class **OpenAIQuickstart**. It imports the Azure AI Vision library.
115
+
#### [API key](#tab/api-key)
57
116
58
-
```kotlin
59
-
plugins {
60
-
java
61
-
application
62
-
}
63
-
application {
64
-
mainClass.set("OpenAIQuickstart")
65
-
}
66
-
repositories {
67
-
mavenCentral()
68
-
}
69
-
dependencies {
70
-
implementation(group ="com.azure", name ="azure-ai-openai", version ="1.0.0-beta.3")
71
-
implementation("org.slf4j:slf4j-simple:1.7.9")
72
-
}
117
+
```java
118
+
OpenAIAsyncClient client = new OpenAIClientBuilder()
119
+
.endpoint(endpoint)
120
+
.credential(new AzureKeyCredential(key))
121
+
.buildAsyncClient();
73
122
```
123
+
---
124
+
125
+
#### [Microsoft Entra ID](#tab/keyless)
126
+
127
+
Follow these steps to create a console application for speech recognition.
128
+
129
+
1. Create a new file named *Quickstart.java*in the same project root directory.
130
+
1. Copy the following code into *Quickstart.java*:
0 commit comments