Using PnP.PowerShell in Azure runbook fails #467
Answered
by
AndersRask
colonelclaypoo
asked this question in
General
Replies: 1 comment
-
Always store all cmdlet calls in variables or use out-null to prevent runbooks from getting suspended and always create runbooks logic as idempotent (it is the build in retry logic that stems from when they were used as workflows that kicks in)
Did you assign O365 graph permissions to the runas service principal in AAD?
Kind regards Anders Rask
On 20 Mar 2021 08.15, colonelclaypoo ***@***.***> wrote:
Hello,
I'm trying to execute the latest PnP.PowerShell in an Azure runbook via an Azure app.
The authentication seems to work just fine. However, the cmdlet fails with the error "User not found" - for whatever reason.
$connection = Get-AutomationConnection –Name "AzureRunAsConnection"
$tenant = '[tenantID]'
$url = 'https://[tenant].sharepoint.com/sites/test'
Connect-PnPOnline -Url $url –Thumbprint "[thumbprint]" –ClientId "[clientID]" -Tenant $tenant -ReturnConnection
Get-PnPWeb
Get-PnPWeb : User cannot be found.
At line:8 char:1
+ Get-PnPWeb
+ ~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPWeb], ServerException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.GetWeb
I tried storing the cmdlet output in a variable and what happens then is that the runbook times out and gets suspended after 3 unsuccessful attempts. The time out happens for other cmdlets, such as Get-PnPTenantSite even without storing them in a variable. Piping into | Out-Null also times out.
The same method (auth via Azure app with certificate) works on a local machine, though.
ExchangeV2 cmdlets work in this environment with the described method.
Anyone observed this too?
Thanks.
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
colonelclaypoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm trying to execute the latest PnP.PowerShell in an Azure runbook via an Azure app.
The authentication seems to work just fine. However, the cmdlet fails with the error "User not found" - for whatever reason.
I tried storing the cmdlet output in a variable and what happens then is that the runbook times out and gets suspended after 3 unsuccessful attempts. The time out happens for other cmdlets, such as Get-PnPTenantSite even without storing them in a variable. Piping into | Out-Null also times out.
The same method (auth via Azure app with certificate) works on a local machine, though.
ExchangeV2 cmdlets work in this environment with the described method.
Anyone observed this too?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions