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 ManagedServiceIdentity.
Client di identità del servizio gestito.
Source code | Package (NPM) | API reference documentation | Samples
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-msi
Installare la libreria client Azure ManagedServiceIdentity per JavaScript con npm:
npm install @azure/arm-msi
Creare ed autenticare un ManagedServiceIdentityClient
Per creare un oggetto client per accedere all'API Azure ManagedServiceIdentity, è necessario disporre endpoint della risorsa Azure ManagedServiceIdentity e di un credentialfile . Il client Azure ManagedServiceIdentity può usare le credenziali di Azure Active Directory per l'autenticazione.
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
Sarà anche necessario registrare una nuova applicazione AAD e concedere l'accesso ad Azure ManagedServiceIdentity 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 { ManagedServiceIdentityClient } from "@azure/arm-msi";
import { DefaultAzureCredential } from "@azure/identity";
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ManagedServiceIdentityClient(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 { 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
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
ManagedServiceIdentityClient
ManagedServiceIdentityClient è l'interfaccia principale per gli sviluppatori che usano la libreria client Azure ManagedServiceIdentity. Esplorare i metodi in questo oggetto client per comprendere le diverse funzionalità del servizio Azure ManagedServiceIdentity 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 AZURE_LOG_LEVEL variabile di ambiente su info. In alternativa, la registrazione può essere abilitata in fase di esecuzione chiamando setLogLevel in @azure/logger:
import { setLogLevel } from "@azure/logger";
setLogLevel("info");
Per istruzioni più dettagliate su come abilitare i log, vedere 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