你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
此包包含适用于 Azure ComputeSchedule 客户端的同构 SDK(在 Node.js 和浏览器中运行)。
Microsoft.ComputeSchedule 资源提供程序管理 API。
Key links:
Getting started
当前支持的环境
- LTS 版本的 Node.js
- 最新版本的 Safari、Chrome、Edge 和 Firefox。
See our support policy for more details.
Prerequisites
安装 @azure/arm-computeschedule
包
使用以下命令 npm
安装适用于 JavaScript 的 Azure ComputeSchedule 客户端库:
npm install @azure/arm-computeschedule
创建和验证 ComputeScheduleClient
要创建客户端对象以访问 Azure ComputeSchedule API,您需要 endpoint
Azure ComputeSchedule 资源的 credential
. Azure ComputeSchedule 客户端可以使用 Azure Active Directory 凭据进行身份验证。
You can find the endpoint for your Azure ComputeSchedule resource in the Azure Portal.
You can authenticate with Azure Active Directory using a credential from the @azure/identity library or an existing AAD Token.
To use the DefaultAzureCredential provider shown below, or other credential providers provided with the Azure SDK, please install the @azure/identity
package:
npm install @azure/identity
您还需要 注册一个新的 AAD 应用程序,并通过 将合适的角色分配给您的服务主体来授予对 Azure ComputeSchedule 的访问权限(注意:此类 "Owner"
角色不会授予必要的权限)。
For more information about how to create an Azure AD Application check out this guide.
使用 Node.js 和类似 Node 的环境,可以使用 DefaultAzureCredential
类对客户端进行身份验证。
import { ComputeScheduleClient } from "@azure/arm-computeschedule";
import { DefaultAzureCredential } from "@azure/identity";
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ComputeScheduleClient(new DefaultAzureCredential(), subscriptionId);
对于浏览器环境,请使用 InteractiveBrowserCredential
包中的 @azure/identity
进行身份验证。
import { InteractiveBrowserCredential } from "@azure/identity";
import { ComputeScheduleClient } from "@azure/arm-computeschedule";
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
tenantId: "<YOUR_TENANT_ID>",
clientId: "<YOUR_CLIENT_ID>",
});
const client = new ComputeScheduleClient(credential, subscriptionId);
JavaScript Bundle
若要在浏览器中使用此客户端库,首先需要使用捆绑程序。 For details on how to do this, please refer to our bundling documentation.
Key concepts
ComputeScheduleClient
ComputeScheduleClient
是使用 Azure ComputeSchedule 客户端库的开发人员的主要接口。 探索此客户端对象上的方法,以了解您可以访问的 Azure ComputeSchedule 服务的不同功能。
Troubleshooting
Logging
启用日志记录可能有助于发现有关故障的有用信息。 若要查看 HTTP 请求和响应的日志,请将 AZURE_LOG_LEVEL
环境变量设置为 info
。 或者,可以在运行时通过调用 setLogLevel
中的 @azure/logger
来启用日志记录:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
有关如何启用日志的更详细说明,请查看 @azure/logger 包文档。
Contributing
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.