[BUG] No SharePoint context for connections authenticated with Managed Identity
Notice
Many bugs reported are actually related to the PnP Framework which is used behind the scenes. Consider carefully where to report an issue:
- Are you using
Invoke-PnPSiteTemplateorGet-PnPSiteTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/pnp/pnpframework/issues. - Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
- If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/pnp/powershell/tree/master/src/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/pnp/pnpframework/issues
Reporting an Issue or Missing Feature
Authenticating with a Managed Identity from either Cloud Shell or an Azure Function results in a token with no SharePoint context, so none of the SharePoint cmdlets work. Graph-using cmdlets (such as -PnPTeams) work as expected. The only audience in the token is https://graph.microsoft.com/.
Expected behavior
Being able to access SharePoint Online objects.
Actual behavior

Steps to reproduce behavior
Connect-PnPOnline -ManagedIdentity Get-PnPContext
What is the version of the Cmdlet module you are running?
1.5.0
Which operating system/environment are you running PnP PowerShell on?
- [ ] Windows
- [ ] Linux
- [ ] MacOS
- [x ] Azure Cloud Shell
- [ x] Azure Functions
- [ ] Other : please specify
Managed Identity is not supported for SharePoint, so these commands won’t work.
@gautamdsheth - Will that be an enhancement at some stage or it's depending on MSFT? Because the issue can be closed if there's nothing we can do at this point.
@veronicageek / @sergeyz7 - It's depending on MSFT , so nothing we can do here. So, closing this.