SPFx – SharePoint Online User Profile Photo Sync


Hi, friends a few days ago I had posted an article on ‘SharePoint Online User Photo Sync.‘ It explains how the user photos displayed in the SharePoint site from the exchange online and also covered on the option for syncing the photos from AAD to SharePoint using PnP Profile Uploader.

In this post, let me introduce you to the SPFx web part that would facilitate the administrator to sync the profile photos from AAD or the FileShares to SharePoint User Profile store.


  • User selection will help you to update only specific user based on the selection. It will also allow the users to fetch the photos from Azure AD before starting the synchronization.
  • Bulk Sync will allow the admin to upload the photos from their file shares. The filename should be in the format ‘UserID.jpg‘.
  • Access control based on SharePoint Group, not all the users can access the application.
  • Separate section to check the status of the photo update.
  • Azure Function to handle the photo update. PnPPowershell is used in Azure Function.
  • The application supports SPA.

Note: All the supporting lists were created when the web part is loaded for the first time. Whenever the web part is loaded, the supported lists were checked whether it exists or not.


  • Select a library to store the thumbnails: A document library to store the thumbnail photos.
  • Delete thumbnail stored: This flag will decide whether you want to keep the thumbnails generated or to clean it after the sync completed.
  • Azure Function URL: Azure function URL to run the photo update.
  • Use Certificate for Azure Function authentication: The video mentioned below to setup Azure Function has different options. This setting will decide whether to use the certificate or stored credentials to communicate with SharePoint.
  • Date format: Date format to be used across the entire application. Used momentJS.
  • SharePoint Groups: Only the users from the configured SharePoint Groups and Site Administrator shall be allowed access.
  • Use page full width: This is used when the web part is added to a site page where it has to use full width.


Source Code

The above web-part is shared with the community and is of free to use. Please click the below link to download the code and have fun.


Happy Coding…

8 thoughts on “SPFx – SharePoint Online User Profile Photo Sync

  1. Pingback: SharePoint PnP Dev SPFx JS SIG Call – October 22nd, 2020 – Screenshot Summary - Warner Digital

  2. I wanted to use your trick to get the full width, so I tested:
    jQuery(“.SPCanvas-canvas”).prop(“style”, “max-width: none”);
    jQuery(“.CanvasZone”).prop(“style”, “max-width: none”);
    But without jQuery
    But sometimes it works because there is 1 item in the array but other times the HTMLCollection is empty.
    Does it always work for you? Any web part?
    Thank you

    Liked by 1 person

  3. Hello Sudharsan, I repeatedly tried and failed to configure the azure function.
    I created a http trigger and and pasted the script ftom assets folder SPUPS_Photo_Sync.ps1 to the run.sp1 in az function. Saved it and then used the azure default-key fucntion URL in the webpart. Saved the webpart and search the user and hit sync. Nothing happens No logs created in the azure functions as well.
    How to debug? Am I missing something?
    I am new to this SPFX world. forgive my ignorance.


    • Hi Aman, thanks for trying out the solution. Let me know what is the issue when you are trying to execute the Azure Function. You can check the issue in the Monitor section of the particular function. There are few configuration params that have to be created for the Function App.
      1. Tenant – Which is the tenant name
      2. ClientID – Client secret
      3. ServiceAccount – SharePoint Administrator account name
      4. ServiceAccountPwd – SharePoint Administrator account pwd
      5. Thumbprint – Certificate thumbprint if you are using cert authentication.

      Please go through the below video for Azure Function


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s