Azure / Azure/terraform-provider-azapi

Microsoft.PolicyInsights/remediations failureThreshold percentage issue

Open
#757 4 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
Go
Stars
244
Forks
97
Avg merge
3d 18h
Merged PRs (30d)
8

Description

A policy remediation is failing for all the deployments and failing the terraform deployment. Tried to set the failureThreshold.percentage to 1 to allow 100% failure but the resource is still failing the deployment. Expected that all the remediation deployments fail and the Microsoft.PolicyInsights/remediations successfully deploys.


│ Error: Failed to create/update resource

│ with module.bootstrap.azapi_resource.policy_remediation_mdfc["migrateToMdeTvm"],
│ on ..\modules\bootstrap\main.tf line 64, in resource "azapi_resource" "policy_remediation_mdfc":
│ 64: resource "azapi_resource" "policy_remediation_mdfc" {

│ creating/updating Resource: (ResourceId
│ "/providers/Microsoft.Management/managementGroups/sd115/providers/Microsoft.PolicyInsights/remediations/deploy-mdfc-config-h224-remediation-migrateToMdeTvm"
│ / Api Version "2024-10-01"): GET
│ https://management.azure.com/providers/Microsoft.Management/managementGroups/sd115/providers/Microsoft.PolicyInsights/remediations/deploy-mdfc-config-h224-remediation-migrateToMdeTvm
│ --------------------------------------------------------------------------------
│ RESPONSE 200: 200 OK
│ ERROR CODE UNAVAILABLE
│ --------------------------------------------------------------------------------
│ {
│ "properties": {
│ "policyAssignmentId": "/providers/microsoft.management/managementgroups/sd115/providers/microsoft.authorization/policyassignments/deploy-mdfc-config-h224",
│ "policyDefinitionReferenceId": "migratetomdetvm",
│ "provisioningState": "Failed",
│ "createdOn": "2025-02-11T02:34:50.2177957Z",
│ "lastUpdatedOn": "2025-02-11T02:36:07.3168601Z",
│ "deploymentStatus": {
│ "totalDeployments": 2,
│ "successfulDeployments": 0,
│ "failedDeployments": 2
│ },
│ "resourceDiscoveryMode": "ExistingNonCompliant",
│ "statusMessage": "All remediation deployments failed.",
│ "correlationId": "eb2f5923-3560-1b72-501d-8ff5d5c664d4",
│ "failureThreshold": {
│ "percentage": 1.0
│ }
│ },
│ "id": "/providers/microsoft.management/managementgroups/sd115/providers/microsoft.policyinsights/remediations/deploy-mdfc-config-h224-remediation-migratetomdetvm",
│ "name": "deploy-mdfc-config-h224-remediation-migrateToMdeTvm",
│ "type": "Microsoft.PolicyInsights/remediations",
│ "systemData": {
│ "createdBy": "d18f16e2-a270-4598-952d-782cc1b5b0f1",
│ "createdByType": "Application",
│ "createdAt": "2025-02-11T02:34:49.9066388Z",
│ "lastModifiedBy": "d18f16e2-a270-4598-952d-782cc1b5b0f1",
│ "lastModifiedByType": "Application",
│ "lastModifiedAt": "2025-02-11T02:34:49.9066388Z"
│ }
│ }
│ --------------------------------------------------------------------------------

Contributor guide

Open the contributing guide

Research direction

Start at modules/bootstrap/main.tf line 64, where the azapi_resource for Microsoft.PolicyInsights/remediations is declared, and inspect how failureThreshold.percentage is passed to the Azure API. Reproduce the two-failed-deployment case and compare the API response with the provider's failure handling; done means a 1% threshold permits the remediation resource to deploy when all remediation deployments fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, terraform
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.