MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.31k stars 21.5k forks source link

Translator service inside VNET always returns {"error":{"code":"404","message": "Resource not found"}} #90691

Closed insomniacc closed 2 years ago

insomniacc commented 2 years ago

Hey, I'm having difficulty getting translation service working from within a vnet. I've followed the doc here: https://docs.microsoft.com/en-us/azure/cognitive-services/cognitive-services-virtual-networks?tabs=portal Steps I've taken:

To aid with troubleshooting, I've configured a VM in my VNET and attempted to run the below code. The custom endpoint hostname does resolve to the correct ip address so I know that dns is working correctly.

I can get the below example working, if I run it from outside the VNET and point it at the public endpoint 'https://api.cognitive.microsofttranslator.com/'. However, when I point at the custom endpoint from my VM inside the VNET i always get the following return: invoke-restmethod : {"error":{"code":"404","message": "Resource not found"}}

$body = @{
    Text = "I would really like to drive your car around the block a few times."
} | convertto-json

$headers = @{
    "Ocp-Apim-Subscription-Key" = "the key from my translator resource"
}
invoke-restmethod -method POST -uri "https://my-translator-service-name.cognitiveservices.azure.com/translate?api-version=3.0&to=zh-Hans" -Headers $headers -ContentType "Application/Json" -body ("[" + $body + "]")

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ram-msft commented 2 years ago

@insomniacc Thanks for the question. We are investigating the issue and will update you shortly.

insomniacc commented 2 years ago

We've managed to figure this one out. Following the article provided in the error/link and here, and also using the reference from 'Keys and Endpoint' on the translator service itself, we assumed this was a like for like swap, e.g

public endpoint: https://api.cognitive.microsofttranslator.com/detect

private endpoint: https://translation-service-resource-name.cognitiveservices.azure.com/detect

Actually, this was not the case, and we finally got it working using the endpoint documented in this article : https://translation-service-resource-name.cognitiveservices.azure.com/translator/text/v3.0/detect

Might be worth adding an additional reference to the change in endpoint format when using custom over public on the aforementioned article, just to make this consistent if it's the only place a user visits.

ram-msft commented 2 years ago

@insomniacc Thanks for the details. We have created backlog to update the document. We will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

cburatto commented 1 year ago

Documentation has not been updated as of 2023-08-07

https://learn.microsoft.com/en-us/azure/ai-services/translator/reference/v3-0-languages

If you follow these instructions but use VNET and private endpoint, you will be lost until you find this issue and comment from @insomniacc

sandeepgoyal84 commented 9 months ago

Thanks @insomniacc for your finding, after struggling 2 days, your post saved further frustration :)