diff --git a/sdk/cognitiveservices/cognitiveservices-computervision/README.md b/sdk/cognitiveservices/cognitiveservices-computervision/README.md index e4067518d8f2..3706a4ac2166 100644 --- a/sdk/cognitiveservices/cognitiveservices-computervision/README.md +++ b/sdk/cognitiveservices/cognitiveservices-computervision/README.md @@ -15,92 +15,75 @@ npm install @azure/cognitiveservices-computervision ### How to use -#### nodejs - Authentication, client creation and listModels as an example written in TypeScript. +#### nodejs - Authentication, client creation and listModels as an example written in TypeScript. -##### Install @azure/ms-rest-azure-js +##### Install @azure/ms-rest-nodeauth +- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. ```bash -npm install @azure/ms-rest-azure-js +npm install @azure/ms-rest-nodeauth@"^3.0.0" ``` ##### Sample code -The following sample describes a given image using Computer Vision. To know more, refer to the [Azure Documentation on Computer Vision](https://docs.microsoft.com/azure/cognitive-services/computer-vision/home) - -```javascript -const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision"); -const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js"); - -async function main() { - const computerVisionKey = process.env["computerVisionKey"] || ""; - const computerVisionEndPoint = - process.env["computerVisionEndPoint"] || ""; - const cognitiveServiceCredentials = new CognitiveServicesCredentials(computerVisionKey); - const client = new ComputerVisionClient(cognitiveServiceCredentials, computerVisionEndPoint); - - const url = - "https://docs.microsoft.com/azure/includes/media/shared-image-galleries/shared-image-gallery.png"; - const options = { - maxCandidates: 5, - language: "en" - }; - client - .describeImage(url, options) - .then((result) => { - console.log("The result is:"); - console.log(result); - }) - .catch((err) => { - console.log("An error occurred:"); - console.error(err); - }); -} - -main(); + +```typescript +import * as msRest from "@azure/ms-rest-js"; +import * as msRestNodeAuth from "@azure/ms-rest-nodeauth"; +import { ComputerVisionClient, ComputerVisionModels, ComputerVisionMappers } from "@azure/cognitiveservices-computervision"; +const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; + +msRestNodeAuth.interactiveLogin().then((creds) => { + const client = new ComputerVisionClient(creds, subscriptionId); + client.listModels().then((result) => { + console.log("The result is:"); + console.log(result); + }); +}).catch((err) => { + console.error(err); +}); ``` -#### browser - Authentication, client creation and listModels as an example written in JavaScript. +#### browser - Authentication, client creation and listModels as an example written in JavaScript. + +##### Install @azure/ms-rest-browserauth + +```bash +npm install @azure/ms-rest-browserauth +``` ##### Sample code -- index.html +See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. +- index.html ```html @azure/cognitiveservices-computervision sample + @@ -111,4 +94,4 @@ main(); - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js) -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcognitiveservices%2Fcognitiveservices-computervision%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/cognitiveservices/cognitiveservices-computervision/README.png)