This post covers using the Azure REST API in PowerShell.
First of you need to install the latest and greatest Azure PowerShell Module on your machine. Best place to do this is to install the good old fashioned MSI available from https://github.com/Azure/azure-powershell/releases
Once you have the latest Azure PowerShell Module on your machine, you’ll need to restart.
The script below will have you Logon to (new) Azure from PowerShell only. Then the script can handle two separate Rest API calls:
- Rest API call against Azure Classic
- Rest API call against Azure ARM
The function for the Rest API auth will handle both Classic & ARM. Feel free to use the script below as a start to test yourself, it doesn’t change anything and only does a ‘GET’ for information.
By the way, if you want to run something similar in the Chrome plugin Postman, this article walks you through it.
To get the Authorization code in the Article, from the PowerShell above, the following will give you what you need and send it direct to the clipboard
$global:authResultASM.CreateAuthorizationHeader() | scb $global:authResultARM.CreateAuthorizationHeader() | scb
This is what the top of Postman should look like: