Partilhar via


Biblioteca de cliente do Azure Atlas para JavaScript - versão 1.0.0

Este pacote contém um SDK isomórfico (executado em Node.js e em navegadores) para o cliente do Azure Atlas.

Key links:

Getting started

Ambientes atualmente suportados

See our support policy for more details.

Prerequisites

Instalar o pacote @azure/arm-mongodbatlas

Instale a biblioteca de cliente do Atlas do Azure para JavaScript com npm:

npm install @azure/arm-mongodbatlas

Criar e autenticar um AtlasClient

Para criar um objeto cliente para acessar a API do Atlas do Azure, você precisará endpoint do recurso do Atlas do Azure e de um credentialarquivo . O cliente do Azure Atlas pode usar as credenciais do Azure Ative Directory para autenticar. 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

Você também precisará registrar um novo aplicativo AAD e conceder acesso ao Atlas do Azure atribuindo a função adequada à sua entidade de serviço (observação: funções como as que "Owner" não concederão as permissões necessárias).

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

Usando ambientes Node.js e Node-like, você pode usar a classe DefaultAzureCredential para autenticar o cliente.

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);

Para ambientes de navegador, use o InteractiveBrowserCredential do pacote @azure/identity para autenticar.

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

Para usar essa biblioteca de cliente no navegador, primeiro você precisa usar um bundler. For details on how to do this, please refer to our bundling documentation.

Key concepts

AtlasClient

AtlasClient é a interface principal para desenvolvedores que usam a biblioteca de cliente do Azure Atlas. Explore os métodos neste objeto de cliente para entender os diferentes recursos do serviço Atlas do Azure que você pode acessar.

Troubleshooting

Logging

Habilitar o registro em log pode ajudar a descobrir informações úteis sobre falhas. Para ver um log de solicitações e respostas HTTP, defina a AZURE_LOG_LEVEL variável de ambiente como info. Como alternativa, o registro em log pode ser habilitado em tempo de execução chamando setLogLevel o @azure/logger:

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

setLogLevel("info");

Para obter instruções mais detalhadas sobre como habilitar logs, você pode consultar os documentos do pacote @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.