此包包含適用於 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 和類似節點的環境,您可以使用 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");
如需如何啟用記錄的詳細指示,請參閱
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.