你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Azure OperationalInsightsManagement client library for JavaScript - version 10.1.0

该包包含一个同构的 SDK(可在 Node.js 和浏览器中运行),用于 Azure OperationalInsightsManagement 客户端。

运营洞察客户

源代码 | 包 (NPM) | API 参考文档 | 样品

入门指南

目前支持的环境

有关更多详细信息,请参阅我们的支持政策

先决条件

安装 @azure/arm-operationalinsights

安装 Azure OperationalInsightsManagement 客户端库,适用于 npmJavaScript:

npm install @azure/arm-operationalinsights

创建和验证 OperationalInsightsManagementClient

要创建客户端对象访问 Azure OperationalInsightsManagement API,你需要 Azure OperationalInsightsManagement 资源中的 endpointcredential 。 Azure OperationalInsightsManagement 客户端可以使用 Azure Active Directory 凭证进行认证。 您可以在 Azure 门户中找到 Azure OperationalInsightsManagement 资源的端点。

可以使用来自 @azure/标识 库的凭据或使用现有 AAD 令牌Azure Active Directory 进行身份验证。

若要使用如下所示的 DefaultAzureCredential 提供程序,或 Azure SDK 提供的其他凭据提供程序,请安装 @azure/identity 包:

npm install @azure/identity

你还需要 注册一个新的AAD应用程序,并通过 将合适的角色分配给你的服务主体,授予Azure运营洞察管理的访问权限(注意:此类 "Owner" 角色不会授予必要的权限)。

有关如何创建 Azure AD 应用程序的详细信息,请参阅本指南

使用 Node.js 和类似 Node 的环境,可以使用 DefaultAzureCredential 类对客户端进行身份验证。

import { OperationalInsightsManagementClient } from "@azure/arm-operationalinsights";
import { DefaultAzureCredential } from "@azure/identity";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new OperationalInsightsManagementClient(
  new DefaultAzureCredential(),
  subscriptionId,
);

对于浏览器环境,请使用 InteractiveBrowserCredential 包中的 @azure/identity 进行身份验证。

import { InteractiveBrowserCredential } from "@azure/identity";
import { OperationalInsightsManagementClient } from "@azure/arm-operationalinsights";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
  tenantId: "<YOUR_TENANT_ID>",
  clientId: "<YOUR_CLIENT_ID>",
});
const client = new OperationalInsightsManagementClient(credential, subscriptionId);

JavaScript 捆绑包

若要在浏览器中使用此客户端库,首先需要使用捆绑程序。 有关如何执行此作的详细信息,请参阅我们的 捆绑文档

重要概念

运营洞察管理客户端

OperationalInsightsManagementClient 是开发者使用 Azure OperationalInsightsManagement 客户端库的主要接口。 探索该客户端对象的方法,了解您可以访问的Azure运营洞察管理服务的不同功能。

Troubleshooting

伐木业

启用日志记录可能有助于发现有关故障的有用信息。 若要查看 HTTP 请求和响应的日志,请将 AZURE_LOG_LEVEL 环境变量设置为 info。 或者,可以通过在 setLogLevel中调用 @azure/logger 在运行时启用日志记录:

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

有关如何启用日志的更详细说明,可以查看 @azure/记录器包文档

后续步骤

请查看 示例 目录,获取有关如何使用此库的详细示例。

Contributing

若要参与此库,请阅读 参与指南 ,详细了解如何生成和测试代码。