mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
Overhauls tests and samples for Azure Cognitive Services for Language SDKs by implementing safe secret standards: - Updates `test-resources.bicep` to not output API keys nor SAS tokens - Updates the tests to retrieve API keys using the arm client - Updates the tests to create SAS tokens for Storage container access - Updates the samples and snippets to use Entra ID authentication - Fix live tests by enabling SAS access to the persistent storage account Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4694655&view=results
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample shows how to programmatically retrieve metadata about the number of custom models in the Form Recognizer
|
|
* resource and the limit of custom models that the resource will allow to be created.
|
|
*
|
|
* @summary get information about the count and limit of custom models in the resource
|
|
*/
|
|
|
|
const DocumentIntelligence = require("@azure-rest/ai-document-intelligence").default,
|
|
{ isUnexpected } = require("@azure-rest/ai-document-intelligence");
|
|
const { DefaultAzureCredential } = require("@azure/identity");
|
|
require("dotenv/config");
|
|
|
|
async function main() {
|
|
const client = DocumentIntelligence(
|
|
process.env["DOCUMENT_INTELLIGENCE_ENDPOINT"] || "<cognitive services endpoint>",
|
|
new DefaultAzureCredential(),
|
|
);
|
|
const info = await client.path("/info").get();
|
|
if (isUnexpected(info)) {
|
|
throw info.body.error;
|
|
}
|
|
console.log(
|
|
`Custom document models: ${info.body.customDocumentModels.count} of ${info.body.customDocumentModels.limit}`,
|
|
);
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("An error occurred:", error);
|
|
process.exit(1);
|
|
});
|