TranslatorService.InitializeAsync Method

Definition

Overloads

InitializeAsync()

Initializes the TranslatorService class by getting an access token for the service.

InitializeAsync(String, String)

Initializes the TranslatorService class by getting an access token for the service.

InitializeAsync()

Initializes the TranslatorService class by getting an access token for the service.

public System.Threading.Tasks.Task InitializeAsync ();
abstract member InitializeAsync : unit -> System.Threading.Tasks.Task
override this.InitializeAsync : unit -> System.Threading.Tasks.Task
Public Function InitializeAsync () As Task

Returns

A Task that represents the initialize operation.

Implements

Exceptions

The SubscriptionKey property hasn't been set.

The provided SubscriptionKey isn't valid or has expired.

Remarks

Calling this method isn't mandatory, because the token is get/refreshed everytime is needed. However, it is called at startup, it can speed-up subsequest requests.

Applies to

InitializeAsync(String, String)

Initializes the TranslatorService class by getting an access token for the service.

public System.Threading.Tasks.Task InitializeAsync (string subscriptionKey, string language = default);
abstract member InitializeAsync : string * string -> System.Threading.Tasks.Task
override this.InitializeAsync : string * string -> System.Threading.Tasks.Task
Public Function InitializeAsync (subscriptionKey As String, Optional language As String = Nothing) As Task

Parameters

subscriptionKey
String

The subscription key for the Microsoft Translator Service on Azure.

language
String

A string representing the supported language code to speak the text in. The code must be present in the list of codes returned from the method GetLanguagesAsync().

Returns

A Task that represents the initialize operation.

Implements

Exceptions

The SubscriptionKey property hasn't been set.

The provided SubscriptionKey isn't valid or has expired.

Remarks

Calling this method isn't mandatory, because the token is get/refreshed everytime is needed. However, it is called at startup, it can speed-up subsequest requests.

You must register Microsoft Translator on https://portal.azure.com to obtain the Subscription key needed to use the service.

Applies to