Compartilhar via


Biblioteca de clientes do Azure Atlas para JavaScript – versão 1.0.0

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

Key links:

Getting started

Ambientes com suporte no momento

See our support policy for more details.

Prerequisites

Instalar o pacote @azure/arm-mongodbatlas

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

npm install @azure/arm-mongodbatlas

Criar e autenticar um AtlasClient

Para criar um objeto de cliente para acessar a API do Azure Atlas, você precisará endpoint do recurso do Azure Atlas e de um credential. O cliente do Azure Atlas pode usar as credenciais do Azure Active 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 Azure Atlas atribuindo a função adequada à entidade de serviço (observação: funções como não "Owner" concederão as permissões necessárias).

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

Usando ambientes semelhantes a Node.js e nó, 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 clientes no navegador, primeiro você precisa usar um empacotador. 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 clientes do Azure Atlas. Explore os métodos nesse objeto de cliente para entender os diferentes recursos do serviço do Azure Atlas 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 variável de ambiente AZURE_LOG_LEVEL como info. Como alternativa, o registro em log pode ser habilitado em runtime chamando setLogLevel no @azure/logger:

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

setLogLevel("info");

Para obter instruções mais detalhadas sobre como habilitar logs, você pode examinar os documentos do pacote @azure/agente.

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.

  • do SDK do Microsoft Azure para JavaScript