0
votes

Looks like I cannot resolve cognition text translate IP address. Ping does not work either. Code example:

let fun = () => {

var key_var = 'mykey';

var endpoint_var = 'https://myendpoint.cognitiveservices.azure.com/translate';


let options = {
    method: 'POST',
    baseUrl: endpoint_var,
    url: 'translate',
    qs: {
        'api-version': '3.0',
        'to': ['de', 'it']
    },
    headers: {
        'Ocp-Apim-Subscription-Key': key_var,
        'Content-type': 'application/json',
        'X-ClientTraceId': uuidv4().toString()
    },
    body: [{
        'text': 'Hello World!'
    }],
    json: true
};

request(options, function (err, res, body) {
    console.log(JSON.stringify(body, null, 4));
    console.log('hello')
    console.log(err);
});
}
 fun();

console out: hello { Error: getaddrinfo EAI_AGAIN myendpoint.cognitiveservices.azure.com myendpint.cognitiveservices.azure.com:443 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26) errno: 'EAI_AGAIN', code: 'EAI_AGAIN', syscall: 'getaddrinfo', hostname: 'myendpoint.cognitiveservices.azure.com', host: 'myendpoint.cognitiveservices.azure.com', port: 443 }

1
that would be a DNS issue not a code issueJaromanda X
Yes, it should be. But I would assume that Microsoft deploys hostname right away, or there is some kind of delay? And I could not find a way to look up IP address of the API in azure console. That would help for sureAdam
how long have you waited?, are you sure you haven't made a typo? e.g. in the code you have myendpint in the error you have myendpoint - typos are easy to makeJaromanda X
It is my second attempt. First time I waited for 5 hours and then deleted and created a new cognition service. Yes, I am typing correctly. I was just replacing the name of the endpoint with "myendpoint" to post here and made a typo.Adam
I realise myendpoint wasn't the real endpoint, I was making a point about typos :p if ping doesn't work, then it's definitely an DNS issueJaromanda X

1 Answers

0
votes

Apparently the link that I have been using is for my personal token provision. Actually latest endpoint could be found here As well there is npm library that made specifically for mstraslation: https://www.npmjs.com/package/mstranslator. It will make you live a bit easier.