This article will show how to create an Azure AI Translator service using the Azure REST API.
Microsoft Azure AI Translator offers translation services like language detection and translation for over 90 languages using a single API endpoint.
The process to use Azure AI Translator starts with the provisioning of an Azure AI Service (Multi-service or Translator) and using an SDK or Azure REST API to utilize the service.
Azure AI Translator offers two core services: Language Detection and Language Translation.To use the detection service, we need to send a text in a key-value pair format with the language we would like to detect.
The translation service uses two parameters, From and To, that indicate the source (From) and target (To) languages. We can also count the number of characters in a translated sentence using built-in functions provided by the API.
To create an Azure AI Translator service (also known as a resource) using the Azure REST API, we need to first create an Entra ID App Registration with the appropriate permissions to create resources. Visit this link to create an App Registration before continuing.
If you are new to the Azure REST API, it allows you to fully manage Azure and its resources using API requests (GET, PUT, DELETE, etc.) and manage the entire lifecycle of any resource running in Azure.
Setting Up Azure AI Translator with REST API
To create a Translator service, we will use a POST request that uses version 2023-05-01 of the Azure REST API. The documentation for this request is available here.
To create a resource, send a PUT request, adding your Azure Subscription ID, the resource group name, and the name of the AI Language service, as shown below:
https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{Resource Group}}/providers/Microsoft.CognitiveServices/accounts/{{Resource Name}}?api-version=2023-05-01
In the request body, use the following:
{
"location": "East US",
"kind": "TextTranslation",
"sku": {
"name": "F0"
}
}
The request body is shown below with a return code of 201, which means that the resource was created successfully.
Trackbacks/Pingbacks