Hi @lakshmi , yes, this should be possible! You can use the Azure Identity package to authenticate with the Translator service using RBAC. The Azure Identity package provides a set of credential types that can be used to authenticate with Azure services, including the Translator service.
To authenticate with the Translator service using Azure Identity, you can use the DefaultAzureCredential
class, which provides a default authentication flow for applications that will be deployed to Azure. The DefaultAzureCredential
class tries several authentication methods in order, including managed identity, Visual Studio Code credential, Visual Studio credential, and Azure CLI credential.
Here's an example of how to authenticate with the Translator service using DefaultAzureCredential
:
using Azure;
using Azure.AI.Translator.DocumentTranslation;
using Azure.Identity;
// Create a new instance of DefaultAzureCredential
var credential = new DefaultAzureCredential();
// Create a new instance of DocumentTranslationClient using the credential
var client = new DocumentTranslationClient(new Uri(endpoint), credential);
// Use the client to call the Translator service
var result = await client.TranslateDocumentAsync(sourceUri, targetUri, "fr");
In this example, endpoint
is the endpoint URL for the Translator service, sourceUri
is the URI of the source document, targetUri
is the URI of the target document, and "fr"
is the target language.
Please let me know if you have any questions and I can help you further.
If this answer helps you please mark "Accept Answer" so other users can reference it.
Thank you,
James