共用方式為


適用於 JavaScript 的 Azure 部署用戶端程式庫 - 1.0.0-beta.1 版

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

Deployments Client

Source code | Package (NPM) | API reference documentation | Samples

Getting started

目前支援的環境

See our support policy for more details.

Prerequisites

安裝 @azure/arm-resourcesdeployments 套件

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

npm install @azure/arm-resourcesdeployments

建立和驗證 DeploymentsClient

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

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

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

import { DeploymentsClient } from "@azure/arm-resourcesdeployments";
import { DefaultAzureCredential } from "@azure/identity";

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

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

import { InteractiveBrowserCredential } from "@azure/identity";
import { DeploymentsClient } from "@azure/arm-resourcesdeployments";

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

JavaScript Bundle

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

Key concepts

DeploymentsClient

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

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.