ACR expansion 401 error #2170
-
Hi all, Hoping someone can nudge me in the right direction here as I've hit a brick wall on this one. I've got this working in my lab with all the same configuration settings & SPN but in my main Azure DevOps project the analysis task gives a 401 unauthorized error and I can't figure out why. I don't know what context it's trying to use in the PSRule task, and even with audit logging turned on my ACR I can't see it being queried to understand that side better.
Pipeline task (sanitised variables group & env names):
bicepconfig.json in root of repo:
psruleassert log:
I've gone over this helpful troubleshooting page(s) but everything seems in-check https://github.com/Azure/PSRule.Rules.Azure/blob/main/docs/troubleshooting.md Has anyone had any similar run-ins who could point me in the right direction, or any solutions? It's almost like it's not respecting the env variables. I've checked the YAML syntax for odd spaces and looks ok to me. Any help is appreciated! Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@riosengineer Your configuration looks good. I assume Thoughts that might help with your further troubleshooting:
Export-PSRuleConvention 'LogVariables' -Initialize {
Write-Host "Using AZURE_CLIENT_ID: $($Env:AZURE_CLIENT_ID)"
Write-Host "Using AZURE_TENANT_ID: $($Env:AZURE_TENANT_ID)"
}
- job: 'PSRuleAnalysis'
displayName: "Run PSRule analysis"
dependsOn: BicepValidation
variables:
- group: keyvaultname
pool:
vmImage: $(vmImageName)
steps:
- task: bewhite.ps-rule.assert.ps-rule-assert@2
inputs:
source: "$(System.DefaultWorkingDirectory)/ps-rule.yaml"
modules: PSRule.Rules.Azure, PSRule.Rules.CAF, PSRule.Rules.Kubernetes
outputFormat: NUnit3
outputPath: "reports/ps-rule-results.xml"
conventions: LogVariables
env:
AZURE_CLIENT_ID: $(spn-)
AZURE_CLIENT_SECRET: $(spn-secret)
AZURE_TENANT_ID: $(tenant) Hopefully that helps. |
Beta Was this translation helpful? Give feedback.
I finally got this working. Turns out, I have to include this into the bicepconfig.json for it to work:
So not a PSRule issue, apologies! But thank you anyway for your detailed reply Bernie!