次の方法で共有


JavaScript 用 Azure Atlas クライアント ライブラリ - バージョン 1.0.0

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

Key links:

Getting started

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

See our support policy for more details.

Prerequisites

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

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

npm install @azure/arm-mongodbatlas

AtlasClient を作成して認証する

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

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

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

import { AtlasClient } from "@azure/arm-mongodbatlas";
import { DefaultAzureCredential } from "@azure/identity";

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

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

import { InteractiveBrowserCredential } from "@azure/identity";
import { AtlasClient } from "@azure/arm-mongodbatlas";

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

JavaScript Bundle

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

Key concepts

AtlasClient

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

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 の