此套件包含 Azure StandbyPoolManagement 用戶端的同型 SDK(在 Node.js 和瀏覽器中執行)。
主要連結:
開始
目前支持的環境
- LTS 版本的 Node.js
- 最新版的 Safari、Chrome、Edge 和 Firefox。
如需詳細資訊,請參閱我們的 支持原則 。
先決條件
安裝 @azure/arm-standbypool 套件
使用 npm安裝適用於 JavaScript 的 Azure StandbyPoolManagement 用戶端連結庫:
npm install @azure/arm-standbypool
建立和驗證 StandbyPoolManagementClient
若要建立用戶端物件來存取 Azure StandbyPoolManagement API,您需要 Azure StandbyPoolManagement 資源的 endpoint 和 credential。 Azure StandbyPoolManagement 用戶端可以使用 Azure Active Directory 認證進行驗證。
您可以在 azure 入口網站 中找到 Azure StandbyPoolManagement 資源的端點。
您可以使用 來自@azure/身分識別 連結庫或 現有 AAD 令牌的認證,向 Azure Active Directory 進行驗證。
若要使用如下所示 的 DefaultAzureCredential 提供者,或 Azure SDK 所提供的其他認證提供者,請安裝 @azure/identity 套件:
npm install @azure/identity
您也必須 註冊新的 AAD 應用程式,並將 適當的角色指派給您的服務主體,以授與 Azure StandbyPool 的存取權(注意:這類 "Owner" 角色不會授與必要的許可權)。
如需如何建立 Azure AD 應用程式的詳細資訊,請參閱本指南 。
使用 Node.js 和類似節點的環境,您可以使用 DefaultAzureCredential 類別來驗證用戶端。
import { StandbyPoolManagementClient } from "@azure/arm-standbypool";
import { DefaultAzureCredential } from "@azure/identity";
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new StandbyPoolManagementClient(new DefaultAzureCredential(), subscriptionId);
針對瀏覽器環境,請使用來自 InteractiveBrowserCredential 套件的 @azure/identity 進行驗證。
import { InteractiveBrowserCredential } from "@azure/identity";
import { StandbyPoolManagementClient } from "@azure/arm-standbypool";
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
tenantId: "<YOUR_TENANT_ID>",
clientId: "<YOUR_CLIENT_ID>"
});
const client = new StandbyPoolManagementClient(credential, subscriptionId);
JavaScript 套件組合
若要在瀏覽器中使用此用戶端連結庫,您必須先使用配套程式。 如需如何執行這項作的詳細資訊,請參閱我們的 統合檔。
重要概念
StandbyPoolManagementClient
StandbyPoolManagementClient 是開發人員使用 Azure StandbyPoolManagement 用戶端連結庫的主要介面。 探索此客戶端物件上的方法,以瞭解您可以存取之 Azure StandbyPoolManagement 服務的不同功能。
故障排除
伐木
啟用記錄可能有助於找出有關失敗的實用資訊。 若要查看 HTTP 要求和回應的記錄,請將 AZURE_LOG_LEVEL 環境變數設定為 info。 或者,您可以在運行時間啟用記錄,方法是在 setLogLevel中呼叫 @azure/logger:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
如需如何啟用記錄的詳細指示,請參閱
後續步驟
如需如何使用此連結庫的詳細範例,請參閱 範例 目錄。
貢獻
如果您想要參與此連結庫,請閱讀 參與指南 ,以深入瞭解如何建置和測試程序代碼。