"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"tags": {
"type": "object",
"metadata": {
"description": "An object containing tags that will be applied to the Storage Account"
}
},
"location": {
"type": "string",
"metadata": {
"description": "A valid Azure location (region)"
}
},
"automationAccountSku": {
"type": "object",
"metadata": {
"description": "An object containing the sku details applied to the storage account"
}
},
"automationAccountName": {
"type": "string",
"metadata": {
"description": "Name of the automation account"
}
},
"PowerShellRunbookName": {
"type": "string",
"metadata": {
"description": "Name of the PowerShell Runbook"
}
},
"logResourceGroupName": {
"type": "string",
"metadata": {
"description": "Resource Group that contains the log resources"
}
},
"logStorageAccountName": {
"type": "string",
"metadata": {
"description": "Stroage Account that contains the resource logs"
}
},
"logAnalyticsName": {
"type": "string",
"metadata": {
"description": "Name of the Log Analytics resource"
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2020-01-13-preview",
"name": "[parameters('automationAccountName')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"sku": {
"name": "[parameters('automationAccountSku')]"
},
"encryption": {
"keySource": "Microsoft.Automation",
"identity": {}
}
},
"resources": [
{
"type": "runbooks",
"apiVersion": "2020-01-13-preview",
"name": "[parameters('PowerShellRunbookName')]",
"location": "[parameters('location')]",
"dependsOn": ["[parameters('automationAccountName')]"],
"properties": {
"runbookType": "PowerShell",
"logProgress": "false",
"logVerbose": "false"
}
}
]
},
{
"type": "Microsoft.Automation/automationAccounts/providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat(parameters('automationAccountName'), '/Microsoft.Insights/', 'resourceLogs')]",
"dependsOn": [
"[resourceId('Microsoft.Automation/automationAccounts', parameters('automationAccountName'))]"
],
"properties": {
"storageAccountId": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('logResourceGroupName'),'/providers/Microsoft.Storage/storageAccounts/', parameters('logStorageAccountName'))]",
"workspaceId": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('logResourceGroupName'),'/providers/microsoft.operationalinsights/workspaces/', parameters('logAnalyticsName'))]",
"logs": [
{
"category": "AutomationAccount",
"enabled": true
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true
}
]
}
}
]
}