Search code examples
azure-policyazure-compliance-policy

How to log GuestAssignment Compliance Status' and output as a CSV


I have the following GuestConfiguration with several compliance status': enter image description here

I want to be able to view these records in the log analytics workspace or something similar and eventually, output the results as a CSV for auditing.


I tried to use the policy assignment. However, this only gives me the overall "is the VM compliant": YES/NO. I'm trying to keep the compliance granularity per VM.


Solution

  • I want to be able to view these records in the log analytics workspace or something similar and eventually, output the results as a CSV for auditing.

    As there is no feature in Log Analytics to export query results to Excel, you can achieve the same scenario by using a Logic App.

    Here is the steps to send Log Analytics query result to CSV using Logic Apps.

    1. Run your KQL query in Log Analytics
    2. Create a below design in Logic App

    enter image description here

    3.After running the Logic App flow, the CSV file generated by the KQL query has been uploaded to the Storage account as shown below.

    enter image description here

    CSV File

    enter image description here

    Reference: Connect to Log Analytics or Application Insights from workflows in Azure Logic Apps