適用於 Node.js 的 Azure Operational Insights 模組Azure Operational Insights Modules for Node.js

使用 npm 來安裝適用於 Node.js 的 Azure Operational Insights 模組參考Use npm to install the Azure Operational Insights module for Node.js

npm install azure-arm-operationalinsights

範例Example

此範例會建立用戶端,連線到 Operational Insights 以及擷取所指定資源群組的工作區清單。This example creates a client, connects to Operational Insights and retreives a list of workspaces by a specified resource group.

const msRestAzure = require('ms-rest-azure');
const OperationalInsightsManagement = require('azure-arm-operationalinsights');

const subscriptionId = 'your-subscription-id';

msRestAzure.interactiveLogin().then(credentials => {
    const client = new OperationalInsightsManagement(
        credentials,
        subscriptionId
    );
    return client.workspaces.listByResourceGroup('resource-group-name');
})
.then(workspaces => {
    console.log(workspaces);
});

範例Samples

深入探索可在應用程式中使用的 Node.js 程式碼範例Explore more sample Node.js code you can use in your apps.