Q. What is Postman and how do I use it with Azure?
Use Postman to interface with REST APIs including Azure
June 22, 2015
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 SDKsAzurePowerShellServiceManagementAzureServicesMicrosoft.IdentityModel.Clients.ActiveDirectory.dll"$adalforms = "${env:ProgramFiles(x86)}Microsoft SDKsAzurePowerShellServiceManagementAzureServicesMicrosoft.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:
Select the environment dropdown in the top right corner and select Manage environments
Click the Add button
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:
Click Submit
in the environment drop down make sure your environment is selected
Next select the Headers tab and select Manage presets and click Add
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:
Click Submit
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.
-->
About the Author
You May Also Like