Issues provisioning sites from Azure Automation using PnP

%3CLINGO-SUB%20id%3D%22lingo-sub-282526%22%20slang%3D%22en-US%22%3EIssues%20provisioning%20sites%20from%20Azure%20Automation%20using%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282526%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20try%20to%20provision%20sites%20using%20PowerShell%20code%20in%20Azure%20Automation%20and%20get%20various%20errors.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20worse%20when%20we%20run%20many%20concurent%20sessions%20but%2C%20in%20the%20current%20case%2C%20even%20a%20single%20instance%20fail.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20error%20we%20are%20curently%20stuck%20on%20says%20something%20like%20%22unable%20to%20find%20user%22%20(our%20error%20is%20in%20french)%3C%2FP%3E%3CP%3EERROR%3A%20Get-PnPWeb%20%3A%20Impossible%20de%20trouver%20l'utilisateur.At%20line%3A57%20char%3A12%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24WEB%20%3D%20Get-PnPWeb%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~~~~~~~~~~%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20WriteError%3A%20(%3A)%20%5BGet-PnPWeb%5D%2C%20ServerException%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20EXCEPTION%2CSharePointPnP.PowerShell.Commands.GetWeb%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20is%20weird%20is%20that%20everything%20happens%20with%20the%20same%20user%20and%20that%26nbsp%3B%3C%2FP%3E%3CP%3EConnect-PnPOnline%20works%3C%2FP%3E%3CP%3EGet-PnPContext%20works%3C%2FP%3E%3CP%3EBut%20Get-PnPWeb%20fails.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20hints%20on%20how%20to%20debug%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20we%20run%20the%20same%20commands%20from%20our%20own%20ISE%20session%20it%20works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F122%22%20target%3D%22_blank%22%3E%40Erwin%20van%20Hunen%3C%2FA%3E%26nbsp%3BI%20see%20your%20name%20everywhere%20in%20the%20GitHub%20so%20I%20mention%26nbsp%3Byou%20in%20case%20you%20could%20help.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-282526%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282688%22%20slang%3D%22en-US%22%3ERe%3A%20Issues%20provisioning%20sites%20from%20Azure%20Automation%20using%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282688%22%20slang%3D%22en-US%22%3E%3CP%3EErwin%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20same%20account.%20It%20didn't%20make%20sense%20for%20us%20because%20we%20always%20connect%20with%20the%20same%20user%20credentials.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20strange%20thing%20is%20that%20the%20same%20code%20runs%20correctly%20most%20of%20the%20times%20but%20sometimes%20errors%20occurs.%20It%20was%20one%20of%20the%20first%20occurence%20where%20the%20error%20was%20constant%20on%20azure%20and%20not%20present%20locally.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20also%20had%20403%20errors%20from%20SPO%20but%20these%20are%20not%20repeatable.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20changed%20the%20code%20a%20little%20(but%20connect%20with%20the%20same%20commands%20sequence)%20and%20restarted%20the%20job.%20We%20then%20had%20a%20lot%20less%20failures%20in%20the%20%C2%B12500%20sites%20that%20were%20provisionned%20in%20our%20test%20environment.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20caring.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282650%22%20slang%3D%22en-US%22%3ERe%3A%20Issues%20provisioning%20sites%20from%20Azure%20Automation%20using%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282650%22%20slang%3D%22en-US%22%3E%3CP%3EI%20just%20tried%20it%20myself%20and%20did%20in%20sequence%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EConnect-PnPOnline%20-Url%20etc.%20etc.%3C%2FP%3E%0A%3CP%3E%24context%20%3D%20Get-PnPContext%3C%2FP%3E%0A%3CP%3E%24web%20%3D%20Get-PnPWeb%3C%2FP%3E%0A%3CP%3E%24web.Title%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eand%20I%20did%20not%20receive%20any%20error%20messages%20or%20issues%20and%20it%20showed%20the%20title%20of%20the%20web%20in%20the%20output.%20I'm%20more%20thinking%20there%20is%20an%20issue%20with%20the%20web%20you're%20connecting%20to%3F%20Like%20no%20access%20with%20the%20account%20you're%20using%20in%20your%20runbook%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-282616%22%20slang%3D%22en-US%22%3ERe%3A%20Issues%20provisioning%20sites%20from%20Azure%20Automation%20using%20PnP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-282616%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Benoit%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20account%20you're%20using%20when%20running%20in%20ISE%20is%20the%20same%20as%20what%20you're%20using%20with%20Connect-PnPOnline%20when%20running%20in%20your%20runbook%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

We try to provision sites using PowerShell code in Azure Automation and get various errors.

 

It is worse when we run many concurent sessions but, in the current case, even a single instance fail.

 

The error we are curently stuck on says something like "unable to find user" (our error is in french)

ERROR: Get-PnPWeb : Impossible de trouver l'utilisateur.At line:57 char:12+     $WEB = Get-PnPWeb+            ~~~~~~~~~~    + CategoryInfo          : WriteError: (:) [Get-PnPWeb], ServerException    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.GetWeb

 

What is weird is that everything happens with the same user and that 

Connect-PnPOnline works

Get-PnPContext works

But Get-PnPWeb fails.

 

Any hints on how to debug that?

 

By the way, we run the same commands from our own ISE session it works.

 

@Erwin van Hunen I see your name everywhere in the GitHub so I mention you in case you could help.  

 

 

3 Replies
Highlighted

Hi Benoit,

 

The account you're using when running in ISE is the same as what you're using with Connect-PnPOnline when running in your runbook?

Highlighted

I just tried it myself and did in sequence:

 

Connect-PnPOnline -Url etc. etc.

$context = Get-PnPContext

$web = Get-PnPWeb

$web.Title

 

and I did not receive any error messages or issues and it showed the title of the web in the output. I'm more thinking there is an issue with the web you're connecting to? Like no access with the account you're using in your runbook?

Highlighted

Erwin,

 

Yes, same account. It didn't make sense for us because we always connect with the same user credentials.

 

The strange thing is that the same code runs correctly most of the times but sometimes errors occurs. It was one of the first occurence where the error was constant on azure and not present locally.

 

We also had 403 errors from SPO but these are not repeatable. 

 

We changed the code a little (but connect with the same commands sequence) and restarted the job. We then had a lot less failures in the ±2500 sites that were provisionned in our test environment.

 

Thanks for caring.