22title : How to configure Microsoft Entra authentication
33titleSuffix : Azure AI services
44description : Learn how to authenticate using Microsoft Entra authentication
5- author : rhurey
5+ author : eric-urban
66manager : nitinme
77ms.service : azure-ai-speech
88ms.topic : how-to
9- ms.date : 1/18 /2024
10- ms.author : rhurey
9+ ms.date : 9/9 /2024
10+ ms.author : eur
1111zone_pivot_groups : programming-languages-set-two
12- ms.devlang : cpp
1312ms.custom : devx-track-azurepowershell, devx-track-extended-java, devx-track-python, devx-track-azurecli
1413---
1514
@@ -186,10 +185,10 @@ For ```SpeechRecognizer```, ```SpeechSynthesizer```, ```IntentRecognizer```, ```
186185::: zone pivot="programming-language-csharp"
187186``` C#
188187string resourceId = " Your Resource ID" ;
189- string aadToken = " Your Azure AD access token" ;
188+ string aadToken = " Your Microsoft Entra access token" ;
190189string region = " Your Speech Region" ;
191190
192- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
191+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
193192var authorizationToken = $" aad#{resourceId }#{aadToken }" ;
194193var speechConfig = SpeechConfig .FromAuthorizationToken (authorizationToken , region );
195194```
@@ -198,10 +197,10 @@ var speechConfig = SpeechConfig.FromAuthorizationToken(authorizationToken, regio
198197::: zone pivot="programming-language-cpp"
199198``` C++
200199std::string resourceId = " Your Resource ID" ;
201- std::string aadToken = " Your Azure AD access token" ;
200+ std::string aadToken = " Your Microsoft Entra access token" ;
202201std::string region = " Your Speech Region" ;
203202
204- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
203+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
205204auto authorizationToken = " aad#" + resourceId + " #" + aadToken;
206205auto speechConfig = SpeechConfig::FromAuthorizationToken(authorizationToken, region);
207206```
@@ -212,7 +211,7 @@ auto speechConfig = SpeechConfig::FromAuthorizationToken(authorizationToken, reg
212211String resourceId = " Your Resource ID" ;
213212String region = " Your Region" ;
214213
215- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
214+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
216215String authorizationToken = " aad#" + resourceId + " #" + token;
217216SpeechConfig speechConfig = SpeechConfig . fromAuthorizationToken(authorizationToken, region);
218217```
@@ -222,7 +221,7 @@ SpeechConfig speechConfig = SpeechConfig.fromAuthorizationToken(authorizationTok
222221``` Python
223222resourceId = " Your Resource ID"
224223region = " Your Region"
225- # You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
224+ # You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
226225authorizationToken = " aad#" + resourceId + " #" + aadToken.token
227226speechConfig = SpeechConfig(auth_token = authorizationToken, region = region)
228227```
@@ -235,10 +234,10 @@ For the ```TranslationRecognizer```, build the authorization token from the reso
235234::: zone pivot="programming-language-csharp"
236235``` C#
237236string resourceId = " Your Resource ID" ;
238- string aadToken = " Your Azure AD access token" ;
237+ string aadToken = " Your Microsoft Entra access token" ;
239238string region = " Your Speech Region" ;
240239
241- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
240+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
242241var authorizationToken = $" aad#{resourceId }#{aadToken }" ;
243242var speechConfig = SpeechTranslationConfig .FromAuthorizationToken (authorizationToken , region );
244243```
@@ -247,10 +246,10 @@ var speechConfig = SpeechTranslationConfig.FromAuthorizationToken(authorizationT
247246::: zone pivot="programming-language-cpp"
248247``` cpp
249248std::string resourceId = " Your Resource ID" ;
250- std::string aadToken = " Your Azure AD access token" ;
249+ std::string aadToken = " Your Microsoft Entra access token" ;
251250std::string region = " Your Speech Region" ;
252251
253- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
252+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
254253auto authorizationToken = " aad#" + resourceId + " #" + aadToken;
255254auto speechConfig = SpeechTranslationConfig::FromAuthorizationToken(authorizationToken, region);
256255```
@@ -261,7 +260,7 @@ auto speechConfig = SpeechTranslationConfig::FromAuthorizationToken(authorizatio
261260String resourceId = " Your Resource ID" ;
262261String region = " Your Region" ;
263262
264- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
263+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
265264String authorizationToken = " aad#" + resourceId + " #" + token;
266265SpeechTranslationConfig translationConfig = SpeechTranslationConfig . fromAuthorizationToken(authorizationToken, region);
267266```
@@ -272,70 +271,24 @@ SpeechTranslationConfig translationConfig = SpeechTranslationConfig.fromAuthoriz
272271resourceId = " Your Resource ID"
273272region = " Your Region"
274273
275- # You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
274+ # You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
276275authorizationToken = " aad#" + resourceId + " #" + aadToken.token
277276translationConfig = SpeechTranslationConfig(auth_token = authorizationToken, region = region)
278277```
279278::: zone-end
280279
281- ### DialogServiceConnector
282-
283- For the ``` DialogServiceConnection ``` object, build the authorization token from the resource ID and the Microsoft Entra access token and then use it to create a ``` CustomCommandsConfig ``` or a ``` BotFrameworkConfig ``` object.
284-
285- ::: zone pivot="programming-language-csharp"
286- ``` C#
287- string resourceId = " Your Resource ID" ;
288- string aadToken = " Your Azure AD access token" ;
289- string region = " Your Speech Region" ;
290- string appId = " Your app ID" ;
291-
292- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
293- var authorizationToken = $" aad#{resourceId }#{aadToken }" ;
294- var customCommandsConfig = CustomCommandsConfig .FromAuthorizationToken (appId , authorizationToken , region );
295- ```
296- ::: zone-end
297-
298- ::: zone pivot="programming-language-cpp"
299- ``` cpp
300- std::string resourceId = " Your Resource ID" ;
301- std::string aadToken = " Your Azure AD access token" ;
302- std::string region = " Your Speech Region" ;
303- std::string appId = " Your app Id" ;
304-
305- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
306- auto authorizationToken = " aad#" + resourceId + " #" + aadToken;
307- auto customCommandsConfig = CustomCommandsConfig::FromAuthorizationToken(appId, authorizationToken, region);
308- ```
309- ::: zone-end
310-
311- ::: zone pivot="programming-language-java"
312- ``` Java
313- String resourceId = " Your Resource ID" ;
314- String region = " Your Region" ;
315- String appId = " Your AppId" ;
316-
317- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
318- String authorizationToken = " aad#" + resourceId + " #" + token;
319- CustomCommandsConfig dialogServiceConfig = CustomCommandsConfig . fromAuthorizationToken(appId, authorizationToken, region);
320- ```
321- ::: zone-end
322-
323- ::: zone pivot="programming-language-python"
324- The DialogServiceConnector is not currently supported in Python
325- ::: zone-end
326-
327280### VoiceProfileClient
328281To use the ``` VoiceProfileClient ``` with Microsoft Entra authentication, use the custom domain name created above.
329282
330283::: zone pivot="programming-language-csharp"
331284``` C#
332285string customDomainName = " Your Custom Name" ;
333286string hostName = $" https://{customDomainName }.cognitiveservices.azure.com/" ;
334- string token = " Your Azure AD access token" ;
287+ string token = " Your Microsoft Entra access token" ;
335288
336289var config = SpeechConfig .FromHost (new Uri (hostName ));
337290
338- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
291+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
339292var authorizationToken = $" aad#{resourceId }#{aadToken }" ;
340293config .AuthorizationToken = authorizationToken ;
341294```
@@ -344,24 +297,24 @@ config.AuthorizationToken = authorizationToken;
344297::: zone pivot="programming-language-cpp"
345298``` cpp
346299std::string customDomainName = " Your Custom Name" ;
347- std::string aadToken = " Your Azure AD access token" ;
300+ std::string aadToken = " Your Microsoft Entra access token" ;
348301
349302auto speechConfig = SpeechConfig::FromHost(" https://" + customDomainName + " .cognitiveservices.azure.com/" );
350303
351- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
304+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
352305auto authorizationToken = " aad#" + resourceId + " #" + aadToken;
353306speechConfig->SetAuthorizationToken (authorizationToken);
354307```
355308::: zone-end
356309
357310::: zone pivot="programming-language-java"
358311```Java
359- String aadToken = "Your Azure AD access token";
312+ String aadToken = "Your Microsoft Entra access token";
360313String customDomainName = "Your Custom Name";
361314String hostName = "https://" + customDomainName + ".cognitiveservices.azure.com/";
362315SpeechConfig speechConfig = SpeechConfig.fromHost(new URI(hostName));
363316
364- // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and AAD access token.
317+ // You need to include the "aad#" prefix and the "#" (hash) separator between resource ID and Microsoft Entra access token.
365318String authorizationToken = "aad#" + resourceId + "#" + token;
366319
367320speechConfig.setAuthorizationToken(authorizationToken);
0 commit comments