[英]How to connect Azure Activity Monitor to Log Analytics Workspace via ARM template
How do I connect Azure Activity Logs to a Log Analytics workspace using an ARM template? 如何使用ARM模板将Azure活动日志连接到Log Analytics工作区? I can connect it via the portal:
我可以通过门户网站连接它:
Or using powershell . 或使用powershell 。
But I've searched far and wide and can't find documentation on how to do this with an ARM template (or whether it's currently possible). 但是我进行了广泛搜索,找不到关于如何使用ARM模板执行此操作的文档(或当前是否可行)。
I've also tried creating the connection and viewing the resource structure in the azure resource explorer (and by fetching the resource in powershell), but there's no difference in the json before and after making the connection 我也尝试过创建连接并在azure资源浏览器中查看资源结构(并通过在powershell中获取资源),但是在建立连接之前和之后的json都没有区别
UPDATE: 更新:
I tried an arm template deployment based on this documentation , which I applied like this: 我根据此文档尝试了arm模板部署, 该文档的用法如下:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"name": "my-loganalytics-workspace-name/AzureActivityLog",
"type": "Microsoft.OperationalInsights/workspaces/dataSources",
"apiVersion": "2015-11-01-preview",
"tags": {},
"properties": {},
"kind": "AzureActivityLog"
}
]
}
But it the deployment doesn't complete (has been running for 30 minutes) and has a vague error: 但是它部署没有完成(已经运行了30分钟),并且有一个模糊的错误:
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/template/operations/A886A53AFF9B2E6C",
"operationId": "A886A53AFF9B2E6C",
"properties": {
"provisioningOperation": "Create",
"provisioningState": "Running",
"timestamp": "2019-03-25T13:54:32.2320046Z",
"duration": "PT21M58.8224235S",
"trackingId": "47915902-f795-482a-a408-de408cd78a30",
"serviceRequestId": "8c153090-c33d-4819-b9c4-8226df6a861e",
"statusCode": "InternalServerError",
"statusMessage": {
"Message": "An error has occurred."
},
"targetResource": {
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/my-resource-group/providers/Microsoft.OperationalInsights/workspaces/my-log-analytics-workspace/dataSources/AzureActivityLog",
"resourceType": "Microsoft.OperationalInsights/workspaces/dataSources",
"resourceName": "my-log-analytics-workspace/AzureActivityLog"
}
}
}
Yes it's possible using portal or PowerShell as explained here -> Connecting Azure Activity Log to Log Analytics instance using PowerShell 是的,可以使用门户或PowerShell,如此处所述-> 使用PowerShell将Azure活动日志连接到Log Analytics实例
I have created it using portal or PowerShell and could get those details using PowerShell as shown in below screenshots, in which the ResourceId parameter shown the resource type 'Microsoft.OperationalInsights/workspaces/dataSources'. 我已经使用门户网站或PowerShell创建了它,并且可以使用PowerShell获取这些详细信息,如以下屏幕截图所示,其中ResourceId参数显示了资源类型'Microsoft.OperationalInsights / workspaces / dataSources'。
So most probably it should be possible via ARM template way as well because I see a ARM template reference for resource type 'Microsoft.OperationalInsights/workspaces/dataSources' as shown here -> https://docs.microsoft.com/en-us/azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/datasources 因此很可能也可以通过ARM模板方式实现,因为我看到资源类型'Microsoft.OperationalInsights / workspaces / dataSources'的ARM模板引用,如下所示-> https://docs.microsoft.com/zh-cn /azure/templates/microsoft.operationalinsights/2015-11-01-preview/workspaces/datasources
Hope this helps!! 希望这可以帮助!! Cheers!!
干杯!!
I found a working example template here . 我在这里找到了一个有效的示例模板。
So my original template needed a different name (must include the subscriptionId) and a linkedResourceId
in the properties
: 因此,我的原始模板需要在
properties
使用其他名称(必须包含subscriptionId)和linkedResourceId
:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"name": "[concat('my-loganalytics-workspace-name', '/', subscription().subscriptionId)]",
"type": "Microsoft.OperationalInsights/workspaces/dataSources",
"apiVersion": "2015-11-01-preview",
"tags": {},
"properties": {
"linkedResourceId": "[concat(subscription().Id, '/providers/microsoft.insights/eventTypes/management')]"
},
"kind": "AzureActivityLog"
}
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.