Skip navigation

Q. What is Postman and how do I use it with Azure?

Q. What is Postman and how do I use it with Azure?

A. Postman is a REST Client that runs as an application inside the Chrome browser. It is very useful for interfacing with REST APIs such as those found in Azure. In the Chrome browser navigate to https://chrome.google.com/webstore then search for Postman and it will show as offered by www.getpostman.com. Click the Add to Chrome button to install the application into your browser. Click Add in the dialog displayed to confirm installation.

 

The Chrome App Launcher will be added to your Desktop and Taskbar. Select the App Launcher and click the Postman icon which will launch the application. You can then type in the various REST calls you wish to make using all the various REST verbs such as GET, POST, PUT etc.

If you wish to use this with Azure you need two pieces of information. You subscription ID and also a JWT (JSON Web Token which is an authorization token). The Subscription ID can be found by viewing the portal and browsing Subscriptions or using Get-AzureSubscription. To get the JWT you will need to run the PowerShell code below making sure to change the adTenant to YOUR tenant. This code is part of code I previously covered in FAQ http://windowsitpro.com/azure/communicate-azure-rest-powershell.


# Load ADAL Assemblies
$adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
[System.Reflection.Assembly]::LoadFrom($adal)
[System.Reflection.Assembly]::LoadFrom($adalforms)

# Set Azure AD Tenant name
$adTenant = "YOURTENANT.onmicrosoft.com" 
# Set well-known client ID for AzurePowerShell
$clientId = "1950a258-227b-4e31-a9cf-717495945fc2" 
# Set redirect URI for Azure PowerShell
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
# Set Resource URI to Azure Service Management API
$resourceAppIdURI = "https://management.core.windows.net/"
# Set Authority to Azure AD Tenant
$authority = "https://login.windows.net/$adTenant"
# Create Authentication Context tied to Azure AD Tenant
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
# Acquire token
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$authHeader = $authResult.CreateAuthorizationHeader()
$authHeader | Out-File jwt.txt

Open the jwt.txt in Notepad and we will use this value next.

In Postman we will configure our Azure environment:

  1. Select the environment dropdown in the top right corner and select Manage environments
  2. Click the Add button
  3. Enter a name for the new environment, for example Azure and then create two key values, one named subscriptionID and one named bearer. For the values use your subscription ID value and for the bearer paste in the entire content of the jwt.txt file previously created. It should look something like the following:
  4. Click Submit
  5. in the environment drop down make sure your environment is selected
  6. Next select the Headers tab and select Manage presets and click Add
  7. Add a preset called Azure and add a Content-Type and Authorization field with a value of application/json for the Content-Type and {{bearer}} for the Authorization as shown:
  8. Click Submit
  9. Now select Add preset and select the Azure preset and the two header values will be added

Your environment is now ready to connect to Azure. In this example I will view all my Resource Groups. Set the verb to GET and type the following as the string:


https://management.azure.com/subscriptions/{{subscriptionID}}/resourcegroups?api-version=2015-01-01

Click Send and you should get a result of all your Resource Groups.

The tool can be used for any type of REST action including creating resources.

-->

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish