Working with Microsoft Identity - Configure Local Development

1 minute read

Securing our applications and data is critical in this day and age. I’ve been working a lot with the new Microsoft identity platform (MSAL) library, so I decided to create a series of blog posts around working with it.

Using Environment Variable

Your setup may vary depending on the IDE you are using, Visual Studio, Jetbrains Rider, IntelliJ, Visual Studio Code, etc. I’m going to show you how to set up your Environment variables to use the DefaultAzureCredentials. For this, you will need the Application (Client) ID, Directory (Tenant) ID, and Client Secret (password) obtained from registering your application with the Azure portal. If you need to register an application, check out the post Register an application.

Windows

  • Open up your environment variables.
  • Enter the following environment variables.
Name Corresponding Value Value
AZURE_CLIENT_ID The Azure application/client id 6c04f5c5-97f7-486d-bbb2-eeeeeeeeee
AZURE_CLIENT_SECRET The client secret/password QPxyBvw3.UE8Bw6AJAt63pWx~BB40deded
AZURE_TENANT_ID The directory/tenant id bee716cf-fa94-4610-b72e-5df4bf5a9999

NOTE These are not real values! :smile:

NOTE Depending on your IDE, Terminal, etc, you may need to restart it after updating these values.

Mac

The procedure may vary depending on your environment/shell. For ZSH/bash, add the following your profile.

1
2
3
export AZURE_CLIENT_ID=6c04f5c5-97f7-486d-bbb2-eeeeeeeeee
export AZURE_CLIENT_SECRET=QPxyBvw3.UE8Bw6AJAt63pWx~BB40deded
export AZURE_TENANT_ID=bee716cf-fa94-4610-b72e-5df4bf5a9999

Next Steps

Any questions, please feel free to send me and email or tweet. Like what you see, watch my stream and/or subscribe to my YouTube channel.

Resources