Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

How to Access Azure REST APIs with Node JS.

In this post, I will show you can access the Azure REST APIs. In order to access the Azure APIs, we need the following details- tenant ID, client ID(application ID), client secret, and subscription ID.

So let’s grab all the above-mentioned details from your Azure portal. Let’s log in to the Azure portal by visiting https://portal.azure.com

How to get tenant ID (Directory ID)

After login click on the Azure Active Directory and then click on Properties, then grab the tenant ID (Directory ID).

How to get tenant ID (Directory ID)

How to get client ID(application ID) / client secret

Now Click on App Registrations and create a new application, I am naming my application node-test-app and its type is Web app/API and Sign-on URL can be anything, so I gave http://localhost

azure active directory app registration
azure active directory app registration create

Click on the app you just created and grab the client ID (application ID) and then click on the settings link and then from the right menu panel select keys to generate the client secret. While generating the client secret select the never expiry option.

azure active directory app registration details
azure active directory app registration key create
azure active directory app registration key details

Grant access to your subscriptions

Now give access to the Azure active directory application to access your subscription. Go to your subscription by clicking on all services and selecting your subscription. Click on access control and click on add button. And the role is going to be the contributor and we want to search for your app we called it node-test-app Click select and then click ok.

azure active directory app subscription permissions

Now your application has access to your subscription so when we make rest API calls it can be done on behalf of your application instead of a user.

How to get a subscription ID

One final thing that we need is a subscription ID, so let’s again click on all services and click on subscription and then copy the subscription ID.

azure active directory subscription id

Now we have all the details that we need to access Azure REST APIs, let’s create a node project.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments