Data/ARMTemplates/loganalytics.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "string",
            "metadata": {
                "description": "Name of the workspace."
            }
        },
        "sku": {
            "type": "string",
            "defaultValue": "pergb2018",
            "metadata": {
                "description": "Pricing tier: PerGB2018 or legacy tiers (Free, Standalone, PerNode, Standard or Premium) which are not available to all customers."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Specifies the location for the workspace."
            }
        },
        "retentionInDays": {
            "type": "int",
            "defaultValue": 120,
            "metadata": {
                "description": "Number of days to retain data."
            }
        },
        "resourcePermissions": {
            "type": "bool",
            "defaultValue": true,
            "metadata": {
                "description": "true to use resource or workspace permissions. false to require workspace permissions."
            }
        },
        "heartbeatTableRetention": {
            "type": "int",
            "defaultValue": 120,
            "metadata": {
                "description": "Number of days to retain data in Heartbeat table."
            }
        }
    },
    "resources": [
        {
            "type": "Microsoft.OperationalInsights/workspaces",
            "apiVersion": "2023-09-01",
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "properties": {
                "sku": {
                    "name": "[parameters('sku')]"
                },
                "retentionInDays": "[parameters('retentionInDays')]",
                "features": {
                    "enableLogAccessUsingOnlyResourcePermissions": "[parameters('resourcePermissions')]"
                }
            }
        },
        {
            "type": "Microsoft.OperationalInsights/workspaces/tables",
            "apiVersion": "2022-10-01",
            "name": "[format('{0}/{1}', parameters('name'), 'Heartbeat')]",
            "properties": {
                "retentionInDays": "[parameters('heartbeatTableRetention')]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.OperationalInsights/workspaces/', parameters('name'))]"
            ]
        }
    ],
    "outputs": {
        "logAnalyticsName": {
            "type": "string",
            "value": "[parameters('name')]"
        },
        "logAnalyticsResourceId": {
            "type": "string",
            "value": "[resourceId('Microsoft.OperationalInsights/workspaces/', parameters('name'))]"
        }
    }
}