There may be a need to log the activity of an Azure Automation Account to Log Analytics, this can of course be done via the Portal but, if deploying in true automated fashion – it would be preferable to implemented via code.
These log categories will be configured along with All Metrics:-
- JobLogs
- JobStreams
- DSCNodeStatus
Enabling Diagnostic settings providers/diagnosticSettings within the Azure Resource will be configured Quite a number of resources deployed via AzureRM can use this template; changing the log categories & AllMetrics if not applicable.
AzureRM Template Resource:
{ "apiVersion": "2015-10-31", "location": "[parameters('LogAnalyticsAutomationRegion')]", "name": "[parameters('AutomationAccountName')]", "type": "Microsoft.Automation/automationAccounts", "properties": { "sku": { "name": "[last(parameters('LinkedLogAnalyticsSKU'))]" } }, "resources": [ { "type": "providers/diagnosticSettings", "name": "[concat('Microsoft.Insights/', parameters('settingName'))]", "dependsOn": [ "[resourceId('Microsoft.Automation/automationAccounts/',parameters('AutomationAccountName'))]" ], "apiVersion": "2017-05-01-preview", "properties": { "name": "[parameters('settingName')]", "workspaceId": "[variables('loganalytics_workspace_resourceid')]", "logs": [ { "category": "JobLogs", "enabled": true, "retentionPolicy": { "days": 0, "enabled": false } }, { "category": "JobStreams", "enabled": true, "retentionPolicy": { "days": 0, "enabled": false } }, { "category": "DscNodeStatus", "enabled": true, "retentionPolicy": { "days": 0, "enabled": false } } ], "metrics": [ { "category": "AllMetrics", "enabled": true, "retentionPolicy": { "enabled": false, "days": 0 } } ] } } ] }
AzureRM Template Parameters:
LogAnalyticsAutomationRegion – Region of where your Log Analytics Account has been deployed to
AutomationAccountName – Automation Account name if already deployed, if not – an Automation Account will be created
LinkedLogAnalyticsSKU – SKU of the Log Analytics Account that your Automation Account will be linked too, in the following format:-
"LinkedLogAnalyticsSKU": { "type": "array", "defaultValue": [ "pernode", "OMS" ], "allowedValues": [ [ "pernode", "OMS" ], [ "free", "free" ] ] },
settingName – Name of the Link between Automation Account & Log Analytics as below:-
loganalytics_workspace_resourceid – LogAnalytics Resource ID, in the following format:-
/subscriptions/<subscriptionID>/resourcegroups/<LogAnalyticsResourceGroupName>/providers/microsoft.operationalinsights/workspaces/<LogAnalyticsName>
2 comments