次の方法で共有


JavaScript 用の Azure ManagedServiceIdentity クライアント ライブラリ - バージョン 2.2.0

このパッケージには、Azure ManagedServiceIdentity クライアント用の同型 SDK (Node.js とブラウザーの両方で実行) が含まれています。

マネージド サービス ID クライアント。

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

Getting started

現在サポートされている環境

See our support policy for more details.

Prerequisites

@azure/arm-msi パッケージをインストールする

JavaScript 用の Azure ManagedServiceIdentity クライアント ライブラリを npm でインストールします。

npm install @azure/arm-msi

ManagedServiceIdentityClient を作成して認証する

Azure ManagedServiceIdentity API にアクセスするためのクライアント オブジェクトを作成するには、Azure ManagedServiceIdentity リソースと credentialendpointが必要です。 Azure ManagedServiceIdentity クライアントは、Azure Active Directory 資格情報を使用して認証できます。 You can find the endpoint for your Azure ManagedServiceIdentity 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 ManagedServiceIdentity へのアクセス権を付与する必要があります (注: "Owner" などのロールでは、必要なアクセス許可は付与されません)。

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

Node.js とノードに似た環境を使用すると、DefaultAzureCredential クラスを使用してクライアントを認証できます。

import { ManagedServiceIdentityClient } from "@azure/arm-msi";
import { DefaultAzureCredential } from "@azure/identity";

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

ブラウザー環境では、InteractiveBrowserCredential パッケージの @azure/identity を使用して認証します。

import { InteractiveBrowserCredential } from "@azure/identity";
import { ManagedServiceIdentityClient } from "@azure/arm-msi";

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

JavaScript Bundle

ブラウザーでこのクライアント ライブラリを使用するには、まず、バンドルを使用する必要があります。 For details on how to do this, please refer to our bundling documentation.

Key concepts

ManagedServiceIdentityClient

ManagedServiceIdentityClient は、Azure ManagedServiceIdentity クライアント ライブラリを使用する開発者向けのプライマリ インターフェイスです。 このクライアント オブジェクトのメソッドを調べて、アクセスできる Azure ManagedServiceIdentity サービスのさまざまな機能を理解します。

Troubleshooting

Logging

ログ記録を有効にすると、エラーに関する有用な情報を明らかにするのに役立つ場合があります。 HTTP 要求と応答のログを表示するには、AZURE_LOG_LEVEL 環境変数を infoに設定します。 または、setLogLevel@azure/logger を呼び出すことによって、実行時にログを有効にすることもできます。

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

setLogLevel("info");

ログを有効にする方法の詳細な手順については、@azure/logger パッケージのドキュメントを参照してください。

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.

  • Microsoft Azure SDK for JavaScript の