Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Azure functions connecting flow to sharepoint with MFA

I am trying to use this tutorial: to set up custom MS Flow triggers using Azure Functions to do stuff with sharepoint docs. So, I followed the tut exactly and only changed my credentials so far. I get the following error telling me that the account is not authorized and I must first browse to the site and enable automatic login



2018-01-03T21:11:01.889 Exception while executing function: Functions.CreateFolder. Microsoft.Azure.WebJobs.Script: One or more errors occurred. Microsoft.SharePoint.Client.Runtime: Cannot contact web site '' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=0, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically., SPRequestGuid=9c003d9e-9090-5000-1519-82d69fd4d838, request-id=9c003d9e-9090-5000-1519-82d69fd4d838, MS-CV=nj0AnJCQAFAVGYLWn9TYOA.0, Strict-Transport-Security=max-age=31536000, X-FRAME-OPTIONS=SAMEORIGIN, SPRequestDuration=29, SPIisLatency=0, MicrosoftSharePointTeamServices=, X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=0, Content-Type=text/plain; charset=utf-8, Date=Wed, 03 Jan 2018 21:11:01 GMT, P3P=CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'.

Not really sure exactly what they mean there, but regardless my login requires mfa. Has anyone tried to do this before, is there something special I need to do when using mfa? Following is the few lines where client connection is made.



string userName = System.Environment.GetEnvironmentVariable("SharePointUser", EnvironmentVariableTarget.Process);

 string password = System.Environment.GetEnvironmentVariable("SharePointPassword", EnvironmentVariableTarget.Process); 

var authenticationManager = new PnPAuthenticationManager(); 

var clientContext = authenticationManager.GetSharePointOnlineAuthenticatedContextTenant(sharePointSiteUrl, userName, password); 

var pnpClientContext = PnPClientContext.ConvertFrom(clientContext);


Any help greatly appreciated.


edit: I've set up app registration in AD and tried using that password as an access token but that didnt work. Also tried giving the app registration extra permissions in AD -> App Registrations -> picked my app -> Required Permissions. Basically, looking for anyone who may have set up a flow with sharepoint and mfa .. or auth management with mfa in general. PLS HELP! Thanks.

Community Support Team
Community Support Team

Re: Azure functions connecting flow to sharepoint with MFA

Hi @nycnfc,


Please check this blog for more details about Azure functions:


It seems that you have enabled MFA on your side, please disable it then try again to see if you will get the same issue.

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Azure functions connecting flow to sharepoint with MFA

It would literally not be legal for me to disable mfa 

Helpful resources


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!


Microsoft Learn

Learn how to build the business apps that you need.


Power Platform World Tour

Find out where you can attend!


Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,878)