lhb6540
lhb6540

Reputation: 15

Is there an API to get the Azure subscription info

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://learn.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://learn.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

Upvotes: 0

Views: 2507

Answers (2)

Dev
Dev

Reputation: 2464

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" 

Upvotes: 0

Stanley Gong
Stanley Gong

Reputation: 12153

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

Upvotes: 0

Related Questions