@Богдан Семенов Thanks for using Microsoft Q&A !!
No, unfortunately, there is no direct API which you can use to fetch user information with photos you can however use Microsoft Graph to achieve your desired results.
So, first you need to use Microsoft Graph to fetch Azure AD users using List Users endpoint which will give you Name, Last name and other attributes, then for each each individual users you need to use Get photo endpoint to get photo information, which will give you binary data of the requested photo.
Microsoft Graph SDK will help you further simplify this approach which is currently available for languages and platforms as listed over here.
Example code using Microsoft Graph SDK to get user properties -
//Get users
var users = await graphClient.Users
.Request()
.Select(e => new
{
e.GivenName,
e.Surname,
e.DisplayName,
e.UserPrincipalName
})
.GetAsync();
Also, sample code to get photo of specific user is as follows -
var graphClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
async (requestMessage) =>
{
requestMessage.Headers.Authorization =
new AuthenticationHeaderValue("Bearer", accessToken);
}));
byte[] bytePhoto;
// Get user photo
using (var pStream = await graphClient.Me.Photo.Content.Request().GetAsync())
{
bytePhoto = ((MemoryStream)pStream).ToArray();
}
var b64Photo = Convert.ToBase64String(photoByte);
Please check this discussion as a reference for getting user photo using Microsoft Graph.
Also, if you want use "Bulk export" feature from Azure portal to export users details (without photo) as a CSV file.
Please let me know if you have any other questions.
----------
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.