共用方式為


適用於 JavaScript 的 Azure HardwareSecurityModules 用戶端程式庫 - 2.0.0 版

此套件包含適用於 Azure HardwareSecurityModules 用戶端的同構 SDK (在 Node.js 和瀏覽器中執行)。

Azure 管理 API 提供一組與硬體安全性模組互動的 RESTful Web 服務。

Key links:

Getting started

目前支援的環境

See our support policy for more details.

Prerequisites

安裝 @azure/arm-hardwaresecuritymodules 套件

使用 npm: 安裝適用於 JavaScript 的 Azure HardwareSecurityModules 用戶端程式庫:

npm install @azure/arm-hardwaresecuritymodules

建立和驗證 AzureDedicatedHSMResourceProvider

若要建立用戶端物件來存取 Azure HardwareSecurityModules API,您將需要 Azure HardwareSecurityModules 資源credential的 和 endpoint 。 Azure HardwareSecurityModules 用戶端可以使用 Azure Active Directory 認證來驗證。 You can find the endpoint for your Azure HardwareSecurityModules 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 HardwareSecurityModules 的存取權 (附註:角色 (不會 "Owner" 授與必要的許可權)。

For more information about how to create an Azure AD Application check out this guide.

使用 Node.js 和類似節點的環境,您可以使用 DefaultAzureCredential 類別來驗證用戶端。

import { AzureHSMResourceProvider } from "@azure/arm-hardwaresecuritymodules";
import { DefaultAzureCredential } from "@azure/identity";

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

針對瀏覽器環境,請使用來自 InteractiveBrowserCredential 套件的 @azure/identity 進行驗證。

import { InteractiveBrowserCredential } from "@azure/identity";
import { AzureHSMResourceProvider } from "@azure/arm-hardwaresecuritymodules";

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

JavaScript Bundle

若要在瀏覽器中使用此用戶端連結庫,您必須先使用配套程式。 For details on how to do this, please refer to our bundling documentation.

Key concepts

AzureDedicatedHSMResourceProvider

AzureDedicatedHSMResourceProvider 是使用 Azure HardwareSecurityModules 用戶端程式庫的開發人員的主要介面。 探索此用戶端物件上的方法,以瞭解您可以存取之 Azure HardwareSecurityModules 服務的不同功能。

Troubleshooting

Logging

啟用記錄可能有助於找出有關失敗的實用資訊。 若要查看 HTTP 要求和回應的記錄,請將 AZURE_LOG_LEVEL 環境變數設定為 info。 或者,您可以在運行時間啟用記錄,方法是在 setLogLevel中呼叫 @azure/logger

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

setLogLevel("info");

如需如何啟用記錄的詳細指示,請參閱@azure/記錄器套件檔。

Next steps

Please take a look at the samples directory for detailed examples on how to use this library.

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.