Hi Matt,
You've done an impressive job building this custom Redis patch schedule policy from scratch )) that's no small feat, and you're really close to getting it working properly.
The issue you're hitting with the existenceCondition is actually quite common when working with child resources in Azure Policy. The policy engine struggles to evaluate properties of nested resources like patchSchedules during compliance checks.
The "No related resources match the effect details" error occurs because the policy engine can't find the Microsoft.Cache/redis/patchSchedules resource during evaluation. Even though it exists in your template, the compliance scan doesn't see it as a separate manageable resource.
For your existenceCondition, try this approach instead
"existenceCondition": { "field": "Microsoft.Cache/redis/patchSchedules/scheduleEntries[*].dayOfWeek", "equals": "Sunday" }
This checks for a specific property within the scheduleEntries array rather than trying to evaluate the array length, which the policy engine handles better.
Also, you're absolutely right about needing the "name" in the details section. It should be:
"name": "[concat(field('name'), '/default')]"
This tells the policy exactly which patchSchedules resource to look for - the 'default' one.
The Azure Policy documentation has good examples of working with nested resources that might give you additional ideas https://free.blessedness.top/en-us/azure/governance/policy/concepts/definition-structure.
Another thing to check is your API versions. You're using 2024-11-01 for patchSchedules, which should be fine, but make sure it matches what's available in your region. Sometimes newer API versions have slightly different behavior in policy evaluations.
If you're still getting compliance issues, try simplifying the existenceCondition to just check if any scheduleEntries exist rather than specific values:
"existenceCondition": { "count": "[field('Microsoft.Cache/redis/patchSchedules/scheduleEntries')]", "greater": 0 }
This might be more reliable than checking the exact array length or specific property values. Hope this helps you get that policy showing compliant
regards,
Alex
and "yes" if you would follow me at Q&A - personaly thx.
P.S. If my answer help to you, please Accept my answer