Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Questo pacchetto contiene un SDK isomorfico (viene eseguito sia in Node.js che nei browser) per il client Azure Atlas.
Key links:
Getting started
Ambienti attualmente supportati
- Versioni LTS di Node.js
- Versioni più recenti di Safari, Chrome, Edge e Firefox.
See our support policy for more details.
Prerequisites
Installare il pacchetto @azure/arm-mongodbatlas
Installare la libreria client di Azure Atlas per JavaScript con npm:
npm install @azure/arm-mongodbatlas
Creare ed autenticare un AtlasClient
Per creare un oggetto client per accedere all'API di Azure Atlas, è necessario disporre endpoint della risorsa Azure Atlas e di un credentialfile . Il client Azure Atlas può usare le credenziali di Azure Active Directory per l'autenticazione.
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
Sarà anche necessario registrare una nuova applicazione AAD e concedere l'accesso ad Azure Atlas assegnando il ruolo appropriato all'entità servizio (nota: ruoli come quelli che "Owner" non concederanno le autorizzazioni necessarie).
For more information about how to create an Azure AD Application check out this guide.
Usando Node.js e ambienti simili a Node, è possibile usare la classe DefaultAzureCredential per autenticare il client.
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);
Per gli ambienti del browser, usare il InteractiveBrowserCredential dal pacchetto di @azure/identity per l'autenticazione.
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
Per usare questa libreria client nel browser, è prima necessario usare un bundler. For details on how to do this, please refer to our bundling documentation.
Key concepts
AtlasClient
AtlasClient è l'interfaccia principale per gli sviluppatori che usano la libreria client di Azure Atlas. Esplorare i metodi in questo oggetto client per comprendere le diverse funzionalità del servizio Azure Atlas a cui è possibile accedere.
Troubleshooting
Logging
L'abilitazione della registrazione può aiutare a individuare informazioni utili sugli errori. Per visualizzare un log di richieste e risposte HTTP, impostare la variabile di ambiente AZURE_LOG_LEVEL su info. In alternativa, la registrazione può essere abilitata in fase di esecuzione chiamando setLogLevel nel @azure/logger:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
Per istruzioni più dettagliate su come abilitare i log, è possibile esaminare la documentazione del pacchetto @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.
Related projects
Azure SDK for JavaScript