In my current project we are using Log Analytics (OMS) to log runs from Logic Apps. From the logged runs we get alerts when a Logic App run is failed. To enable Logic Apps diagnostics we first used a PowerShell script, run from a VSTS release step.
Param ([string]$resourceName) $omsWorkspace = (Get-AzureRmOperationalInsightsWorkspace) $resources = Find-AzureRmResource -ResourceType Microsoft.Logic/workflows -ResourceNameContains $resourceName foreach ($resource in $resources) { Set-AzureRmDiagnosticSetting -ResourceId $resource.ResourceId -WorkspaceId $omsWorkspace.ResourceId -Enabled $true }
The problem with this is that both the log and metric are enabled.
Since we did not need the Metrics to be enabled we had to do it in another way. After some investigation on the net we found out that it was possible to add it to our ARM template.
Enable Logic Apps Diagnostics within ARM Template
The “resources” array should be within the “Microsoft.Logic/workflows” resource in the template, same level as “type”, “name” etc.
{ "type": "Microsoft.Logic/workflows", "name": "[parameters('logicAppName')]" .. "resources": [ { "type": "providers/diagnosticSettings", "name": "[concat('Microsoft.Insights/', parameters('diagnosticSettings_name'))]", "dependsOn": [ "[parameters('logicAppName')]" ], "apiVersion": "2017-05-01-preview", "properties": { "name": "[parameters('diagnosticSettings_name')]", "workspaceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('diagnosticSettings_resourceGroupName'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('diagnosticSettings_workspaceName'))]", "logs": [ { "category": "WorkflowRuntime", "enabled": true, "retentionPolicy": { "days": 0, "enabled": false } } ], "metrics": [ { "category": "AllMetrics", "enabled": false, "retentionPolicy": { "days": 0, "enabled": false } } ] } } ] }
After deploying the template the metric checkbox is now unchecked.
This example shows only how to configure diagnostic settings for Log Analytics. It is also possible to configure diagnostic settings for Storage Account or Event Hub.
More information
More detailed information about Logic Apps diagnostic settings can be found at Microsoft Azure documentation.
The diagnostics settings are now included in the LogicAppTemplateExtractor by Jeff Hollan, (my first contribution to a github project).