Not able to fetch subscription details - azure

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:

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.

Getting list of all documents from share point

I am trying to implement functionality where I can get list of documents from share-point.I have tried this demo code from Azure directory implementation and login to account and also got details about sites and user data from graph API.
https://github.com/Azure-Samples/ms-identity-android-kotlin
I am able to get site data from graph API :
But when I am trying to get list then getting error or no value
I have also passed this authorization token to REST API but that too doesn't work.
You can try with scope Sites.ReadWrite.All instead of User.read, as I tested it using Graph Explorer and I got access denied as the scope permission was not consented. After I consent the permission, it worked .
Example 1:
Before Consent:
After Constent:
I have created a test list on the Communication Site.
After that when I query for lists , I successfully get the above one I created.
Example 2 :
I also tested it using a Application registered to Azure AD. It didn't return me any error or any value as well when I queried for lists using that app's credential's from Powershell.
After I add Sites.ReadWrite.All to the App's API permission's .
I can successfully get the Values of the lists.
To summarize it , it could be resolved in 2 ways :
Changing the Scope shown on the screenshot given by you to Sites.ReadWrite.All instead of User.Read.
Adding API permissions to the APP registration in the Azure AD for Microsoft Graph as shown in the example 2 second image.

How to get list of Azure Subscriptions and other details during login

I want to make the user login in my custom application and Get the list of Tenants and Once I Get i want to make other Graph API calls like getting list of Azure Resource Groups etc
I want to build a similar experience just like we see in Microsoft Documentation (Try It) section. So that to get details from Users Azure Account i wont have to create Azure AD application in their Subscription
For e.g.

Calling Microsoft Graph API from Azure Functions

I am not sure if I am on the right path, but I am attempting to retrieve my contacts within an Azure Function. I don't need to present a login as this is only for my account. I just want to be able to retrieve my Contacts from the Graph without having to explicitly authenticate. Is this possible? My attempts have failed and I ultimately get stuck trying to add permission...
When I click to add Permission, I get this error:
I am trying to use AAD to authenticate. I tried creating the function within the Portal and also from VS. Any suggestions? Thanks!!
You could follow the steps below to fix the issue.
1.Navigate to the Authentication / Authorization of your function app, click the red frame part like the screenshot.
Go to Manage Permissions -> Add -> select the Windows Azure Active Directory API and Sign in and read user profile permission
Then refresh the portal, it will work fine.

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