Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

The type initializer for 'Microsoft.Graph.PowerShell.Authentication.Common.ProtectedFileProvider' threw an exception.

Open adhodgson1 opened this issue 11 months ago • 7 comments

I'm doing lots of exports through Azure Devops pipeline runs and these fail intermittently with the above error. I can't work out what is going on, think it may be related to subsequent export runs on the same Windows build agent.

Module version: 1.24.313.1 Command: Export-M365DSCConfiguration -MaxProcesses 8 -Components AADAdministrativeUnit -Path Output/AAD -FileName AADAdministrativeUnit.ps1 -CertificateThumbprint $($certificate.Thumbprint) -TenantId $TenantName -ApplicationId $ApplicationID

Output: Exporting Microsoft 365 configuration for Components: AADAdministrativeUnit Authentication methods specified:

  • Service Principal with Certificate Thumbprint Partial Export file was saved at: C:\Users\AzDevOps\AppData\Local\Temp\5802d33c-e961-486f-a9d1-9dda01982199.partial.ps1 ##[error]The type initializer for 'Microsoft.Graph.PowerShell.Authentication.Common.ProtectedFileProvider' threw an exception.

I've tried running with verbose but it doesn't show anything extra in that stage.

adhodgson1 avatar Mar 25 '24 21:03 adhodgson1

Did you include the following steps in your pipeline:


Update-M365DSCDependencies
Uninstall-M365DSCOutdatedDependencies

This error looks like an issue with the preinstalled versions in the pipeline host.

andikrueger avatar Mar 27 '24 15:03 andikrueger

Yes those commands are being issued on pipeline runs. The host we are using is a private ADO build agent. I actually resolved this by getting the team that runs these agents to recycle the agent after every run, so its something going on with the agent after an export. Still not sure what is causing it, seems also to be intermittent. Prefer recycled build agents anyway.

adhodgson1 avatar Apr 03 '24 11:04 adhodgson1

I'm having the exact same issue. Have you made any progress on this or you have stuck to recycling the agents? #4622

jadamones avatar Apr 30 '24 15:04 jadamones

We’re recycling the agents. For us it was happening on an export, running the DSC resources didn’t seem to be a problem. I gave up trying to work out the cause.

adhodgson1 avatar Apr 30 '24 17:04 adhodgson1

@adhodgson1 Thanks for the response and, yeah, same issue here. I'm attempting to run an export job task in the same pipeline that I'm running the compliance check script from the whitepaper. I've discovered that running it in a completely separate pipeline works just fine, but I want this task to run after the compliance test fails. When you say that you are recycling agents, does that mean that you are destroying the VMs and creating new ones just for the one job or are you doing something different like agent maintenance?

jadamones avatar May 01 '24 17:05 jadamones

Our agents are in a VMSS pool and the pool on the ADO end is set to recycle agents.

adhodgson1 avatar May 02 '24 09:05 adhodgson1