2

Is there any way to delete all the Run history logs from a logic app.

I know there is a preview on "Log Retention Time" right now being tested but the most frequent time to delete all logs is once every week. I need to be able to do it more frequent, in this case every 3rd day.

Is there any other way to delete logic app logs/history?

EDIT: Looking at the PowerShell commands in Azure resource manager for a specific run there are only two actions that the Azure resource manager API supports. GET and CANCEL (which I guess is cancel a run while it is running).

SteveC
  • 15,808
  • 23
  • 102
  • 173
H4p7ic
  • 1,669
  • 2
  • 32
  • 61

2 Answers2

2

It is possible to delete each run separately.

So first get all Runs (filtered or not filtered).

Workflow Runs List

with runId you can delete this runs runs.

Workflow Run Delete

You need a similar Http-Request to to delete a run:

DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/runs/{runName}?api-version=2016-06-01

For the autorization yout need a bearer token, I am not sure but I think you get it on powershell with that commands:

az connect
az account get-access-token

Then you got s.th. like this:

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyIsImtpZCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuY29yZS53aW5kb3dzLm5ldC8iLCJpchfhfh3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83ZjFmYTBjMi1mYzMzLTQwZjItYmFiMy03ZWEwMWY1NjgwOTMvIiwiaWF0IjoxNjE5NjIxMDk0LhfhfhfhuYmYiOjE2MTk2MjEwOTQsImV4cCI6MTYxOTYyNDk5NCwiYWNyIjoiMSIsImFpbyI6IkFXUUFtLzhUQUFBQVZmTlRQdDVZSENLZWNCcXlSTk8vaERSZXN3bGd4ME9ndmpNYk9ISG1uck44L0F3YkJOY05NK1NsTytqaHVrTEF0TWx0dDhBNE1BN09pZ3QwaFpDOVovRmRKb2xTM3FkK1ZvdnE4TUo5Q2Rrei9Eb2o2VXNvTjY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Lknt6ERNnSR773LlL8bmm527m29jNzpQGb51r41PM5QxcwHS3mKlMyD894lwhnV-Z6dcXlLc3zmXcDmVRKjMKPFV6c6RBJUlKvaQK-IHMpmqe3SagvCI5r0ETNDus5qK_nd0zSo-b1nsquZ8SlNJsZFnC5b39C1GdsHZdU6dis61vkg_Gpy1tNJ4JjtbqgQHxnpcBYVbEe7OacejMK2rV_Z0sr2Ij00O91YBuI8f-soE4Ot_SsAbhQ82ZhkLHA

So if parsing your run history, you could delete with that command runs that e.g. older than 1 day.

The only problem is now for me. It worked perfect in the browser on the microsoft site, on powershell I got the problem to send a valid post or the token is invalid.

If i get this working will post it here.

ingo_ww
  • 171
  • 1
  • 13
0

A workaround would be to recreate the logic app which would get rid of the run history. If you have your Logic App deployment scripted, you can delete it and redeploy it as required.

If you want to do it manually, you can clone it with a new name, delete the original one, clone the cloned one using the original name, and then delete the clone.

HTH.

Paco de la Cruz
  • 2,066
  • 13
  • 22
  • Deleting and redeploying the logic app would be an option if the logic app didn't have a connection to a system that can send messages through it randomly. hens the up-time has to be consistent and reliable. Renaming it, on creating a new one would mess up the integration as it is connected to some places by resource name. Isn't there anything i could do using the Graph-Api or alike? Where are there logs stored? – H4p7ic Sep 20 '18 at 08:02
  • @John You could couple decouple connection to the logic using APIM or Function App proxy. Then any name change of the logic app would affect the user, as you'd just repoint the APIM / FA proxy at the new logic app – SteveC May 07 '20 at 09:06