Azure / ALZ-Bicep

This repository contains the Azure Landing Zones (ALZ) Bicep modules that help deliver and deploy the Azure Landing Zone conceptual architecture in a modular approach. https://aka.ms/alz/docs
MIT License
764 stars 514 forks source link

Azure DevOps deployment troubleshooting #907

Open pejuborg opened 2 days ago

pejuborg commented 2 days ago

How do I troubleshoot Azure PowerShell / Bicep deployment issues?

I'm struggling to get my Azure DevOps deployment of ALZ-Bicep to work, there are quite a few tweaks that must be done.

My latest hurdle is an error that I don't know how to find the root cause to.

When running the step "Built-in and Custom Policy Assignments Deployment" it fails with the error "Error: Code=; Message=Received unexpected type Newtonsoft.Json.Linq.JObject", and there is nothing that explains what causes this exception.

Code of Conduct

cspring86 commented 2 days ago

I've just upgraded to v0.20.0 and I'm now getting this error too.

I'm getting it on the following steps:

The first two steps fail, but eventually pass after a number of re-tries, however the last step never succeeds and hence fails the whole pipeline.

cspring86 commented 2 days ago

To add, it looks like it's happening on the bicep build command.

If I run this locally with the same version of Bicep, it works perfectly.

Chris031196 commented 2 days ago

I am encoutering this exact issue, too, but only since today. Everything worked great yesterday, so something must have changed since yesterday. Shouldn't be a v0.20.0 issue, since I have used that since around it was released...

cspring86 commented 2 days ago

Maybe an Azure DevOps runner issue?

jtracey93 commented 2 days ago

Is someone able to confirm the versions of bicep and the az powershell modules running on their hosted runners to help us troubleshoot further?

Might also be worth trying to pin the az powershell module version as per https://github.com/Azure/ALZ-Bicep/wiki/KnownIssues#issue-1-what-if-check-fails-within-azure-devops-pipelinegithub-actions-workflow-with-the-error-additional-content-found-in-json-reference-object-a-json-reference-object-should-only-have-a-ref-property-path-parresourcelockconfigdefaultvalue

@Chris031196 @cspring86 @pejuborg

Cc: @oZakari

cspring86 commented 2 days ago

My versions are:

pejuborg commented 2 days ago

I've been able to test with earlier versions of Bicep with no luck. My suspicion is Az PowerShell 13.

jtracey93 commented 2 days ago

V13.0.0 came out yesterday 🤷‍♂️ so I'd put my money there. https://www.powershellgallery.com/packages/Az/13.0.0

Can someone pin to an older version and retry. Say 12.4.0?

Following the guidance I shared in the previous comment

pejuborg commented 2 days ago

Doing it as we "speak"!

The step "Check Az PowerShell Version" is not authored to work with other than the latest version, but the other PowerShell steps seem to.

pejuborg commented 2 days ago

Pinning Az PS to 12.5.0 makes the step "Built-in and Custom Policy Assignments Deployment" succeed.

cspring86 commented 2 days ago

Pinning the AZ pwsh module to 12.4.0 has worked for me.

However, with 13.0.0 on my local machine, it works as well; I can't re-create the issue locally. I've tried in bash and pwsh.

oZakari commented 1 day ago

Thank you, everyone, for reporting the issue and pitching in with troubleshooting—teamwork truly makes the dream work! For now, I’ve updated the Known Issues Wiki with all the information you’ve provided.

Starting tomorrow, I’ll dive deeper into troubleshooting this and will also open an issue with the relevant team(s) to get things moving.

As it stands, I'm wondering if it's associated to the ADO Azure PowerShell task considering that @cspring86 confirmed it worked fine locally with the latest version. That said, if anyone is using GitHub Actions for their pipelines and running into the same issue, please let me know!