0
votes

I created a web app that use microsoft account to login,then it wil perform a series of Azure related operations on behalf of the web app user automally . The doc of Azure API and Graph API give many clear examples to control Azure,But I noticed that most operations require a Azure subscription ID , i can get subscription ID on the portal of auzre , but can't find the method to get it by the api .This will make my web app's user need to get subscription ID on the azure portal to the next step ,it make user feel upset.

I try to find the method in doc of Azure API and Graph API. However,
in the doc of Graph API ,I only find the doc about the subcription of microsoft account's event (https://docs.microsoft.com/en-us/graph/api/subscription-list?view=graph-rest-1.0&tabs=http) ;
In the doc of Azure API, I only find the doc about the operation of subscription (https://docs.microsoft.com/en-us/rest/api/subscription/2018-03-01-preview/subscriptionoperations/list)

I couldn't find the api to get current user's subcription info , Is there an API to get the Azure subscription info or just i didn't find it

2
I think this is the closest one. You need to access Azure's management Apis, for example, to list the subscriptions you can use this endpoint: "GET management.azure.com/subscriptions{subscriptionId}?api-version=2020-01-01" and to get information about a specific subscription you can use this endpoint "GET management.azure.com/subscriptions?api-version=2020-01-01"Dev
Test it and let me know if the above helps.Dev
Moving this to answer. Consider accepting it as answer and upvote it. So it can be useful to others in the community as well :)Dev

2 Answers

0
votes

Just use the API below to get Azure subscription IDs:

Request URL:

GET https://management.azure.com/subscriptions?api-version=2019-06-01

Request Header:

Authorization: Bearer <access token>

Result:

enter image description here

0
votes

You need to access Azure's management Apis, for example,

To list the subscriptions you can use this endpoint:

"GET management.azure.com/subscriptions{subscriptionId}?api-version=2020-01-01" 

and to get information about a specific subscription you can use this endpoint

"GET management.azure.com/subscriptions?api-version=2020-01-01"