简体   繁体   中英

How to access Azure logic app run log by another logic app

I have build an Integration between two systems using Azure Logic Apps. As per some Audit requirements I want to get Logic app run log into a kind of excel report and send it to Audit team by an another scheduled logic app in kind of Excel format.

So basically this is about accessing some Logic App's run log from another logic app..

Can someone provide me a guidance on this??

For this requirement, I can provide a sample for your reference:

1. Create a "Log Analytics workspace" and add "Logic Apps Management" in it, you can refer to this tutorial .

2. Create a new logic app and configure the "Diagnostic settings", please refer to the steps on this tutorial .

3. After completing the configuration above, please wait for a few minutes and then run your logic app serval times for test (The logs in Log Analytics workspace will be a little bit of a delay, I wait for more than 30 minutes. It just show the logs of running instance which run after 30 minutes of the "Diagnostic settings" deployment).

4. Go to your "Log Analytics workspace", click "Workspace summary" --> "Logs". 在此处输入图像描述

There are four query samples for logic app to query the logs, you can also write some other queries to query the logs which you want. 在此处输入图像描述

I just use the third query sample to query the logs distribution by status, we can see there are two success and one failed. 在此处输入图像描述

5. Then create another logic app to get the logs and generate the excel. First add "Run query and list results(preview)" action and copy the query sample to the "Query" box. 在此处输入图像描述 在此处输入图像描述

6. Run the logic app, we can see the logs result show as below format.

{
  "value": [
    {
      "LogicAppName": "huryLogLogic",
      "NumberOfExecutions": 1,
      "RunStatus": "Failed",
      "Error": "ActionFailed"
    },
    {
      "LogicAppName": "huryLogLogic",
      "NumberOfExecutions": 2,
      "RunStatus": "Succeeded",
      "Error": ""
    }
  ]
}

7. As I don't know how to generate the excel in logic app, so in my logic app I generated csv instead. Use " Create CSV table " action to generate the csv. 在此处输入图像描述

8. After running the logic app, the logs in csv shown as below. You can transfer the csv to your code or other service and convert it to excel. 在此处输入图像描述

Hope it helps~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM