Transient failures when deploying a module that deploys a module #4852
-
Hello all, I have a policy file file that looks a bit like this:
I also have an initiative file that uses the policy from above, as a module, like this:
And to top it all off, I then have a policy assignment file (
And to deploy this, I run
When I run this, I get a transient deployment failure:
And yet when I look in the Portal, I can see that the initiative called The annoying thing is, when I attempt all of this without modules (i.e. policy and initiative as "inline resources" all in one file), everything works perfectly the first time round. It's almost as if the use of modules/nested deployments creates a race condition causing the initiative assignment to fail. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Since your policy name matches your module name, then you reference it, that should add a dependson in your json template.
// this should add the dependson: ProductNameTagOnResource_InheritFromRG_IfMissing.name
policyDefinitionId: extensionResourceId(mgId, 'Microsoft.Authorization/policyDefinitions', ProductNameTagOnResource_InheritFromRG_IfMissing.name)
// also for this: taggingInitiative.name
policyDefinitionId: extensionResourceId(mgId, 'Microsoft.Authorization/policySetDefinitions', taggingInitiative.name) you can right click on the bicep file and build to the json template to confirm that, you should see a dependson. Do you have this in a public repo? I would like to test deploy it myself to figure out what is going on? You can test with an explicit dependson as well, as below... like I say I don't think this is needed in this specific case, however test it out. resource Tagging 'Microsoft.Authorization/policySetDefinitions@2020-09-01' = {
name: 'Initiative-Tagging'
properties: {
policyType: 'Custom'
displayName: 'Initiative-Tagging'
description: 'Initiative-Tagging'
metadata: {
category: 'Tags'
}
parameters: {}
policyDefinitions: [
{
policyDefinitionId: extensionResourceId(mgId, 'Microsoft.Authorization/policyDefinitions', ProductNameTagOnResource_InheritFromRG_IfMissing.name)
}
]
}
dependsOn: [
ProductNameTagOnResource_InheritFromRG_IfMissing
]
} |
Beta Was this translation helpful? Give feedback.
Since your policy name matches your module name, then you reference it, that should add a dependson in your json template.