An Azure service to easily conduct machine translation with a simple REST API call.
Hello @Rishikesh S ,
Welcome to Microsoft Q&A .Thank you for reaching out to us.
Based on the details provided, Azure Translator supports authentication using Managed Identity (Microsoft Entra ID) and an Azure Function App can securely access the service without using keys. The observed 401 PermissionDenied response typically indicates a configuration mismatch
The issue usually arises due to misalignment in one or more of the following:
- RBAC role assignment
- Token scope (audience)
- Endpoint configuration
- Network restrictions
Please check if the following steps help-
- Validating RBAC Role Assignment
- Confirm that the Function App managed identity is assigned:
- Cognitive Services User
- Please note that
- This role enables data-plane (API) access
- Cognitive Services Contributor only provides management permissions and is not sufficient for API authorization
- Confirm that the Function App managed identity is assigned:
- Validating token scope nsure the access token is requested with the following scope:
https://cognitiveservices.azure.com/.defaultAn incorrect scope or audience will result in a 401 PermissionDenied response - Validating endpoint configuration Use one of the supported endpoint patterns: Custom Subdomain Endpoint -
https://<resource-name>.cognitiveservices.azure.com/translator/text/v3.0/translateRequires only:-
Authorization: Bearer <token>
https://api.cognitive.microsofttranslator.comRequires additional header -Ocp-Apim-ResourceId: <Translator Resource ID> -
- Validating network configuration If the Translator resource has any of the following enabled:
- Selected Networks
- Private Endpoint
- Virtual Network (VNet)
- Public Translator endpoint access is restricted
- Requests must go through the private/VNet endpoint
- Token-based (Managed Identity) authentication may not be supported in this mode
- Use key-based authentication through the private endpoint
- Or adjust network configuration if Managed Identity authentication is required
Thus, to resolve the issue, ensure the following are correctly configured:
- Managed Identity is enabled on the Function App
- Cognitive Services User role is assigned at Translator resource scope
- Token scope is:
https://cognitiveservices.azure.com/.default - Correct endpoint is used:
- Custom endpoint (recommended), or
- Global endpoint with required headers
- Network configuration allows access (or corresponding auth method is used)
Once these are aligned, Managed Identity authentication for Azure Translator should function successfully.
The following references might be helpful , please check them out
- Authentication and authorization in Azure Translator in Foundry Tools service - Foundry Tools | Microsoft Learn
- Enable Microsoft Entra ID authentication - Foundry Tools | Microsoft Learn
- Translate behind firewalls - Azure Translator - Foundry Tools | Microsoft Learn
- Custom subdomains - Foundry Tools | Microsoft Learn
- Managed Identities - Azure App Service | Microsoft Learn
Thank you
Please "Accept" the answer with an "Upvote" by clicking on "Accept Answer" and thumbs-up button if the response was helpful. This will be benefitting other community members who face the same issue.