Azure / azure-sdk-for-node

Azure SDK for Node.js - Documentation
https://github.com/Azure/azure-sdk-for-node#documentation
MIT License
1.19k stars 567 forks source link

`azureRegion cannot be null` #4143

Closed anton-bot closed 5 years ago

anton-bot commented 5 years ago

I am trying to use the code for Computer Vision from here:

const { CognitiveServicesCredentials } = require('ms-rest-azure');

// Creating the Cognitive Services credentials
// This requires a key corresponding to the service being used (i.e. text-analytics, etc)
let credentials = new CognitiveServicesCredentials('MY LICENSE KEY FROM AZURE PORTAL');

const vision = require('azure-cognitiveservices-vision');

let client = new vision.ComputerVisionAPIClient(credentials);
let fileStream = fs.createReadStream('pathToSomeImage.jpg');
client.analyzeImageInStreamWithHttpOperationResponse(fileStream, {
  visualFeatures: ["Categories", "Tags", "Description"]
}).then((response) => {
  console.log(response.body.tags);
  console.log(response.body.description.captions[0]);
}).catch((err) => {
  throw err;
});

This produces an error:

'azureRegion' cannot be null.

computerVisionAPIClient.js:2590:13

There is no mention of any azureRegion anywhere in the documentation.

Can you check if this an error in the documentation or in the code? Thanks.

scottbell commented 5 years ago

This worked for me: const region = "westus"; let client = new vision.ComputerVisionAPIClient(credentials, region);

scottbell commented 5 years ago

I had to look at the constructor source code of ComputerVisionAPIClient to figure this out though.

ghost commented 5 years ago

I just merged a PR (https://github.com/Azure/azure-sdk-for-node/pull/4197) that should resolve this problem. Please reopen this issue if the problem isn't fixed.