Use Azure Storage Table REST API with AAD token via PostMan

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

You can refer to below steps for scenarios in which you have an application special requirement and need to call raw Storage table REST API from your dev environment via Postman. It consists of two main HTTP requests: first, to authenticate directly using AD security principal to get access token, second an authenticated storage REST API call for Table Storage.

 

Documentation related

 

Prerequisites

 

To follow the steps in this article you must have:

  • Azure subscription
  • An Azure AD tenant
  • Registered application (AD Service principal)

 

Steps to reproduce this scenario:

 

  1. Acquire oAuth 2.0 token:

 

  1. Created security principal for application (Azure portal > AAD > app registrations). Documentation reference: https://docs.microsoft.com/en-us/rest/api/servicebus/get-azure-active-directory-token#register-your-app-with-azure-ad
  2. Assigned Storage Table Data Reader role at storage account level to SP created in step #1 (waited for 30 mins)jumontoy_0-1629297449879.png

     

  3. Used Postman to get the Azure AD token:

 

  • Launch Postman.
  • For the method, select GET.
  • For the URI, enter https://login.microsoftonline.com/<TENANT ID>/oauth2/token. Replace <TENANT ID> with the tenant ID value you copied earlier.
  • On the Headers tab, add Content-Type key and application/x-www-form-urlencoded for the value.

 

jumontoy_1-1629297449884.png

 

  • Switch to the Body tab and add the following keys and values.
  • Select form-data.
  • Add grant_type key, and type client_credentials for the value.
  • Add client_id key, and paste the value of client ID you noted down earlier.
  • Add client_secret key, and paste the value of client secret you noted down earlier.
  • Add resource key, and type https://storage.azure.com/ for the value

 

jumontoy_2-1629297449892.png

 

  • Select Send to send the request to get the token. You see the token in the result. Save the token (excluding double quotes). You will use it later

jumontoy_3-1629297449902.png

                                       

  1. Called Query Entities storage REST API and passed the oAuth 2.0 token from previous step

 

  • In Postman, open a new tab.
  • Select GET for the method.
  • Enter URI in the following format: https://<account>.table.core.windows.net /<table>(). Replace <account> with the name of the Storage Account name. Replace <table> with the name of the table.
  • On the Headers tab, add the following three headers.
  • Add Authorization key and value for it in the following format: Bearer <TOKEN from Azure AD>. When you copy/paste the token, don't copy the enclosing double quotes.

 

jumontoy_4-1629297449910.png

 

  • Select Send to get the entities from table. You see the status as OK with the code 200 as shown in the following image.

 

jumontoy_5-1629297449918.png

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.