Search code examples
azureazure-app-configuration

Node.js application hosted on Azure App service need to use MSI to authenticate to Azure App Config


I have a Node.js application that need to read its configuration from Azure App.config.

When I go through the following example:

https://learn.microsoft.com/en-us/javascript/api/overview/azure/app-configuration-readme?view=azure-node-latest

I read:

AppConfigurationClient can authenticate using a service principal or using a connection string.

How can I have AppConfigurationClient authenticate using MSI (Managed Service Identity) ?


Solution

  • You will need to use the @azure/identity package for javascript. More details can be found at

    https://learn.microsoft.com/en-us/javascript/api/overview/azure/identity-readme

    For managed identity, you will need to create a ManagedIdentityCredential and pass it to the App Configuration client. An example can be found at

    https://github.com/Azure/azure-sdk-for-js/blob/@azure/identity_2.0.4/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity

    You may also like to check out DefaultAzureCredential. It can fall back to different credentials (including managed identity) in different environments. Examples can be found at

    https://github.com/Azure/azure-sdk-for-js/blob/@azure/identity_2.0.4/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-defaultazurecredential