azure - 如何配置逻辑应用以登录到 ARM 模板中的 Log Analytics?

标签 azure azure-resource-manager azure-log-analytics

我正在尝试使用逻辑应用部署解决方案,我希望将其日志数据转到 Log Analytics 工作区。通过诊断设置 > 添加诊断设置 > 选中“发送到 Log Analytics”并选择预先存在的工作区,可以轻松在门户中进行配置。

但是,通过查看逻辑应用、工作区或整个资源组的导出模板,我看不到如何在 ARM 模板中配置此链接。文档似乎也根本没有提及此设置。

最佳答案

以下是流式传输到事件中心\存储帐户\日志分析的示例:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the Logic App that will be created."
            }
        },
        "testUri": {
            "type": "string",
            "defaultValue": "https://azure.microsoft.com/status/feed/"
        },
        "settingName": {
            "type": "string",
            "metadata": {
                "description": "Name of the setting. Name for the diagnostic setting resource. Eg. 'archiveToStorage' or 'forSecurityTeam'."
            }
        },
        "storageAccountName": {
            "type": "string",
            "metadata": {
                "description": "Name of the Storage Account in which Diagnostic Logs should be saved."
            }
        },
        "eventHubAuthorizationRuleId": {
            "type": "string",
            "metadata": {
                "description": "Resource ID of the event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to."
            }
        },
        "eventHubName": {
            "type": "string",
            "metadata": {
                "description": "Optional. Name of the event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category."
            }
        },
        "workspaceId": {
            "type": "string",
            "metadata": {
                "description": "Log Analytics workspace ID for the Log Analytics workspace to which logs will be sent."
            }
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "name": "[parameters('logicAppName')]",
            "apiVersion": "2016-06-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "definition": {
                    "$schema": "https://schema.management.azure.com/schemas/2016-06-01/Microsoft.Logic.json",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "testURI": {
                            "type": "string",
                            "defaultValue": "[parameters('testUri')]"
                        }
                    },
                    "triggers": {
                        "recurrence": {
                            "type": "recurrence",
                            "recurrence": {
                                "frequency": "Hour",
                                "interval": 1
                            }
                        }
                    },
                    "actions": {
                        "http": {
                            "type": "Http",
                            "inputs": {
                                "method": "GET",
                                "uri": "@parameters('testUri')"
                            },
                            "runAfter": {}
                        }
                    },
                    "outputs": {}
                },
                "parameters": {}
            },
            "resources": [
                {
                    "type": "providers/diagnosticSettings",
                    "name": "[concat('Microsoft.Insights/', parameters('settingName'))]",
                    "dependsOn": [
                        "[resourceId('Microsoft.Logic/workflows', parameters('logicAppName'))]"
                    ],
                    "apiVersion": "2017-05-01-preview",
                    "properties": {
                        "name": "[parameters('settingName')]",
                        "storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
                        "eventHubAuthorizationRuleId": "[parameters('eventHubAuthorizationRuleId')]",
                        "eventHubName": "[parameters('eventHubName')]",
                        "workspaceId": "[parameters('workspaceId')]",
                        "logs": [
                            {
                                "category": "WorkflowRuntime",
                                "enabled": true,
                                "retentionPolicy": {
                                    "days": 0,
                                    "enabled": false
                                }
                            }
                        ],
                        "metrics": [
                            {
                                "timeGrain": "PT1M",
                                "enabled": true,
                                "retentionPolicy": {
                                    "enabled": false,
                                    "days": 0
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

https://learn.microsoft.com/en-us/azure/azure-monitor/platform/diagnostic-logs-stream-template

关于azure - 如何配置逻辑应用以登录到 ARM 模板中的 Log Analytics?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57805073/

相关文章:

azure - 在 Log Analytics 工作区下的 Azure 资源中设置 Azure Function 时出错

用于获取所有列名称的 Azure KQL 查询

azure - 通过 PowerShell 创建的 IotHub 设备不显示

c# - 如何在 CosmosDB 查询上使用缓存

visual-studio - VS 2015 Azure 发布向导不处理 ARM 创建的资源吗?

azure - 使用 AzureRm 模块创建 VM 花费太多时间

azure - 默认情况下,Azure 子网中的 VM 之间的所有端口是否均开放

c# - 如何在禁用 TLS1/SSL3 的情况下连接到 Azure 数据库

azure - ARM,如何使参数文件依赖于其他参数

c# - Serilog + Azure - Log Analytics 工作区中没有出现自定义日志