I'm attempting to use the Azure REST API to create an Azure application that, as the first step, pulls all the subscriptions within an organization.
I'm using this guide, referenced from these Microsoft docs. guide: https://blog.jongallant.com/2017/11/azure-rest-apis-postman/ docs: https://docs.microsoft.com/en-us/rest/api/azure/
I'm using the following Azure CLI command to create the service principal:
az ad sp create-for-rbac -n "<name>"
Currently, I can use the resulting service principal successfully in Postman to pull back 1 subscription when I hit:
GET https://management.azure.com/subscriptions?api-version=2016-06-01
However, this response gives only 1 subscription but in the Azure portal I see multiple subscriptions under the organization.
I've tried specifying scope like the following, but I can't seem to get it to work:
az ad sp create-for-rbac -n "<name>" --scope "/"
# OR
az ad sp create-for-rbac -n "<name>" --scope "/subscriptions"
Last bit of useful information, if I run the following in Powershell, I get back multiple subscriptions. This is a synonymous call that I want to find a way to run for the REST API:
Get-AzureRmSubscription
How can I create one service principal that has access to all of the subscriptions under the org? Or is there another way to do this?