Skip to content

[BUG] New-PnPSiteFileVersionExpirationReportJob does not work with managed identity #5107

@bansalanshuman

Description

@bansalanshuman

Description

I am trying to create a SPO site file version expiration report job using an Azure Function that uses a managed identity.
The Connect-PnPOnline command works fine, but when I run New-PnPSiteFileVersionExpirationReportJob it fails.

Error Message

It throws the below error:

NFORMATION: System.Management.Automation.PSInvalidOperationException: Cannot call this API with an app-only principal.
at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPConnectedCmdlet.cs:line 101
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 121
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()

Also, my requirements.psd1 has this entry:
'PnP.PowerShell' = '2.12.0'

Expected behavior

I should be able to generate the reports using managed identity if I am able to connect to the site.

Actual behavior

The command fails with the error above (Cannot call this API with an app-only principal.).

Image

Steps to reproduce behaviour

Create an Azure function app, enable identity and then grant rights to the app(I have Sites.FullControl.All), then create a simple http triggered function and connect the site using command Connect-PnpOnline
run the command New-PnPSiteFileVersionExpirationReportJob

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • [X ] Azure Functions
  • Other : please specify

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions