I have a translator app in azure and it's connected with VNET and an app service which is also connected with VNET both have different subnets but while calling the translate api it's returning
{ "StatusCode": 404, "Content": "{\"error\":{\"code\":\"404\",\"message\": \"Resource not found\"}}" }
this is the endpoint, I'm including the required headers `https://{MYDOMAIN}.cognitiveservices.azure.com/translate?api-version=3.0&to=it
I've tried alot but still getting 404, if anyone experienced same?
-
Check the private endpoint DNS resolution, ensure the App Service’s VNET is linked to the Translator API’s private DNS zone.Dasari Kamali– Dasari Kamali2025年03月06日 10:14:05 +00:00Commented Mar 6 at 10:14
1 Answer 1
Use the below endpoint in the Azure Portal under the Translator resource. Make sure the Virtual Network and Text translator resources are in same region.
https://<ResourceName>.cognitiveservices.azure.com/translator/text/v3.0/translate?api-version=3.0
enter image description here
If you are using a private endpoint, the Translator domain has to resolve to the private IP address. That happens through a Private DNS Zone named privatelink.cognitiveservices.azure.com
, with a record that points to the private endpoint. Without that, the domain won’t resolve correctly inside the VNET.
The App Service should be integrated with the VNET using regional integration, ensuring that all outbound traffic is routed through the VNET. The Route All
option in the integration settings enables this by directing requests, such as those to the Translator API, through the VNET instead of the public internet.
Try the below curl
command :
curl -X POST "https://<ResourceName>.cognitiveservices.azure.com/translator/text/v3.0/translate?api-version=3.0&from=en&to=fr&to=zu" -H "Ocp-Apim-Subscription-Key: <SubscriptionKey>" -H "Ocp-Apim-Subscription-Region: eastus" -H "Content-Type: application/json" --data "[{\"text\":\"Hello Kamali. How are you?\"}]"
Output :
enter image description here
The API needs all three headers: subscription key, region, and content type. Without the region header, the request will often fail even if everything else is right.
On the networking side, if the Translator resource is restricted to selected networks, traffic from the app has to go through the private endpoint. Temporarily setting the Translator to accept all networks can help confirm whether the issue is with the access controls.