Is there an API to get the Azure subscription info - azure

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

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:

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"

Related

Using Managed EWS API ResolveName to get contact's Azure object ID

I am successfully using ResolveName to get most of the contact information I need.
Below is the code I am using:
PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
NameResolutionCollection match = await mailClient.Service.ResolveName(customerEmail, ResolveNameSearchLocation.DirectoryOnly, true, itempropertyset);
I am querying against my Office365/Azure AD tenant.
One of the values I need is not being returned though.
I would like to get the user/contact's Object ID as shown in the Azure Portal - Azure Active Directory - Users - Basic Info screen.
Is that possible using EWS Managed API?
Regards.
You cannot get Azure AD user's object ID using EWS Managed API. Alternatively, you can make use of Microsoft Graph API.
I tried to reproduce the same in my environment via Graph Explorer and got below results:
I have Azure AD user named Sri in my tenant with below properties:
To get the Azure AD user's details via Graph API, I ran below query:
GET https://graph.microsoft.com/v1.0/users/user_principal_name
Response:
To get only object ID of an Azure AD user, you can include $select in the query like below:
GET https://graph.microsoft.com/v1.0/users/user_principal_name?$select=id
Response:
Before running the above queries, make sure to grant consent to required permissions like below:
Go to Graph Explorer -> Modify permissions -> Click on Consent
You will get consent screen and click on Accept like below:
After granting the consent, you can run the queries successfully.

How to fetch User role in specific Subscription based on the user mail id

How to check the users role(owner, reader) in that specific azure subscription by using user mail id has parameter in azure rest apis?
is there any api to get the data has mentioned above?
(or)
is there any api to fetch total users list with user roles in that specific subscription ?
There are two APIs available to fetch user roles
Azure Active Directory Graph API (old)
Microsoft Graph graph.microsoft.com (new).

How to get AD user for Azure subscription Classic Administrators?

My goal is to get the Azure AD users who have been assigned the Classic Administrator role in an azure subscription.
I use the REST api's Classic Administrators - List to retrieve all classic admins but it returns an Email which is not unique enough and an ID called netId/puid which is not present on the user returned from the Graph API.
I followed the Azure Portal's network to see how it gets the users for AAD but it queries the Graph API with an internal API version '1.61-internal' that I can't use.
Does anyone know on a way to retrieve this information?
Thanks
There is not an exposed API to match netId/puid with users.
But you can get the puid from the access token.
Or you could use Microsoft 365 Powershell cmdlet Get-MsolUser -UserPrincipalName "{upn}" | fl to get the user and find the LiveId property.
Record the puid or LiveId above and the corresponding user information to your local configuration file and match them with the name property in response of Classic Administrators - List.
Then you can get the corresponding users who are classic Administrators.
It's just a workaround and there are many workloads. I don't think it is a good method but there is no other way.

Not able to fetch subscription details

I have a multi tenant azure application. When i am trying to fetch subscription details using azure management api, it is always giving null.
I have followed all the steps except step3 mentioned in this post
Fetching VM details from multiple tenants
Its seems that you are trying to get azure subscription Information.
Try with REST API:
GET https://management.azure.com/subscriptions
Note: Refer to this docs. Then click on Try it section.
See the screen shot:
Click on Try it. you will prompt to login login with your credential. After that you will be given option for which tenant you want to get subscription. In response you would get your information like below:

Is there a way to get Azure Subscription ID programmatically?

We would like to create some Azure resources using Azure Rest APIs through a C# program. We are able to get access token by following the below msdn doc
https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code .
But the Azure Rest APIs also requires Subscription ID which we are not able to get. Is there a way we can get it through program?
Thanks
Balaji
You can use the below request URI to get list of subscriptions for a tenant. https://management.azure.com/subscriptions?api-version=2016-06-01
Please refer to Get Subscription List for more information.

Resources