I have an Azure Function which is using PnpPowershell. I'd like to work with the users authorization. So I created a service which is getting an OAuth token from Microsoft for the user. I then give the token to the Azure Function to use it to connect via Connect-PnpOnline.
Connect-PnpOnline -AccessToken $token -Url $url
Apply-PnPProvisioningTemplate "Template.xml"
Connect-PnpOnline executes without any errors/warnings, but Apply-PnpProvisioningTemplate raises the following error: The current connection holds no SharePoint context. Please use one of the Connect-PnPOnline commands which uses the -Url argument to connect.
I'd have expected the connection to be in place. I can use this token to query the MS Graph, so I'd have expected it to be valid. Does anyone have tried something similar and have an idea how to solve the issue?
Found this: