How to get the status of the Remediate State programaticaaly while creating policies (Python SDK)

Anitha Singamsetti 1 Reputation point
2021-08-24T13:42:38.33+00:00

Actually we are trying to create the custom policies using Python SDK.
So we were able to create policy definition, policy assignment and also the policy remediation.
But, the remediation state is in the process of evaluating...We don't want to wait until
it completes. So, I am trying to find out the way like, how to get the status of the remediation state when it completes via python SDK...Can anyone please help me in this issue

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
799 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jesse Loudon 336 Reputation points MVP
    2022-02-07T00:30:42.11+00:00

    hi @Anitha Singamsetti

    I can see there's 4 methods available via the Azure SDK for Python related to your need:

    • get_at_management_group - Gets an existing remediation at management group scope.
    • get_at_resource - Gets an existing remediation at resource scope.
    • get_at_resource_group - Gets an existing remediation at resource group scope.
    • get_at_subscription - Gets an existing remediation at subscription scope.

    more info from Microsoft Learn here https://learn.microsoft.com/en-us/python/api/azure-mgmt-policyinsights/azure.mgmt.policyinsights.aio.operations.remediationsoperations?view=azure-python

    for example;

    get_at_management_group(management_group_id: str, remediation_name: str, **kwargs) -> azure.mgmt.policyinsights.models._models_py3.Remediation  
    

    will return Remediation, or the result of cls(response) https://learn.microsoft.com/en-us/python/api/azure-mgmt-policyinsights/azure.mgmt.policyinsights.models.remediation?view=azure-python

    0 comments No comments

  2. Marwa Abouawad 281 Reputation points Microsoft Employee
    2022-10-10T14:35:15.717+00:00

    Hi @Anitha Singamsetti

    I am following up to check if you still need any further help.

    0 comments No comments