azure-sdk-for-js/sdk/newrelicobservability/arm-newrelicobservability/samples-dev/monitoredSubscriptionsListS...

47 строки
1.6 KiB
TypeScript

/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { NewRelicObservability } from "@azure/arm-newrelicobservability";
import { DefaultAzureCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
/**
* This sample demonstrates how to List the subscriptions currently being monitored by the NewRelic monitor resource.
*
* @summary List the subscriptions currently being monitored by the NewRelic monitor resource.
* x-ms-original-file: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-01-01/examples/MonitoredSubscriptions_List.json
*/
async function monitorsGetMonitoredSubscriptions() {
const subscriptionId =
process.env["NEWRELICOBSERVABILITY_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
const resourceGroupName =
process.env["NEWRELICOBSERVABILITY_RESOURCE_GROUP"] || "myResourceGroup";
const monitorName = "myMonitor";
const credential = new DefaultAzureCredential();
const client = new NewRelicObservability(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.monitoredSubscriptions.list(
resourceGroupName,
monitorName,
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
monitorsGetMonitoredSubscriptions();
}
main().catch(console.error);