Diagnostic settings remediation¶
The foundation assigns the Deploy-Diag-LogsCat policy. It adds a diagnostic
setting to supported resources when they are created or updated, sending them
to the central Log Analytics workspace. A resource that existed before the
policy gets nothing until a remediation task runs.
Everything the bootstrap creates exists before the policy, including the runner Container Apps environment and its registry. The bootstrap sets no diagnostic settings of its own, so runner logs are not stored until this procedure has run. Run it once, after the first foundation apply.
Trigger a compliance scan per subscription first:
Then create one remediation task for each policy in the initiative.
<management-group-id> is where the assignment sits, the root of the landing
zone hierarchy (alz by default):
mg=<management-group-id>
set_id=$(az policy assignment show \
--name Deploy-Diag-LogsCat \
--scope "/providers/Microsoft.Management/managementGroups/$mg" \
--query policyDefinitionId -o tsv)
for ref in $(az policy set-definition show --name "${set_id##*/}" \
--query 'policyDefinitions[].policyDefinitionReferenceId' -o tsv); do
az policy remediation create \
--name "remediate-diag-$ref" \
--management-group "$mg" \
--policy-assignment Deploy-Diag-LogsCat \
--definition-reference-id "$ref" \
--no-wait -o none
done
A task with nothing to fix succeeds with no deployments, so running this again is harmless.
To confirm the runner environment, look for a setByPolicy-LogAnalytics
setting, then start a runner and allow about ten minutes for its logs to appear
in ContainerAppConsoleLogs: