microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.64k stars 505 forks source link

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

Open adhodgson1 opened 8 months ago

adhodgson1 commented 8 months ago

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:

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

andikrueger commented 8 months ago

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.

adhodgson1 commented 8 months ago

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.

jadamones commented 7 months ago

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

adhodgson1 commented 7 months ago

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.

jadamones commented 7 months ago

@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?

adhodgson1 commented 7 months ago

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

acmcg commented 1 month ago

Been getting this same error using on-prem runners across several versions of the PS modules.