Last updated on November 21, 2022
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 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
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.
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.
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.
Now we have all the details that we need to access Azure REST APIs, let’s create a node project.