gpt4 book ai didi

azure - 如何使用 ARM 模板为 Azure 资源创建事件日志诊断设置

转载 作者:行者123 更新时间:2023-12-03 00:47:21 25 4
gpt4 key购买 nike

我们正在引用此文档 here其中讨论使用资源管理器模板在 Azure 中创建诊断设置

我们已成功使用 ARM 模板以及资源日志的诊断设置来配置资源,但文档中的片段可启用 activity logs诊断设置似乎不起作用,因为模板部署命令 (new-azresourcegroupdeployment) 返回错误请求错误。

New-AzResourceGroupDeployment : Resource Microsoft.Insights/diagnosticSettings 'test-vnet' failed with message '{ "Code": "BadRequest", "Message": "" }'

这是模板(修剪了一些代码以避免噪音)

{  
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
...
},
"variables": {
...
},
"resources": [
{
"apiVersion": "2018-08-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('resourceLocation')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"subnets": "[parameters('subnets')]",
"dhcpOptions": {
"dnsServers": "[parameters('dnsServers')]"
}
},
"resources":
[
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[variables('diagnosticsSettingsName')]",
"dependsOn": [
"[parameters('virtualNetworkName')]"
],
"location": "global",
"properties":
{
"storageAccountId": "..valid_id_here",
"logs":
[
{
"category": "Administrative",
"enabled": true
},
{
"category": "Security",
"enabled": true
},
{
"category": "ServiceHealth",
"enabled": true
},
{
"category": "ResourceHealth",
"enabled": true
}
]
}
}
]
}
],
"outputs": {
..
}

最佳答案

文档 here您在创建诊断设置时提到的。

所以,如果您检查 Deployment Methods在本文档中,它表示您可以使用任何有效的方法(包括 PowerShell 和 CLI)部署资源管理器模板。 事件日志的诊断设置必须使用 az deployment create(对于 CLI)或 New-AzDeployment(对于 PowerShell)部署到订阅

使用 New-AzDeployment 而不是 New-AzResourceGroupDeployment 来部署 ARM 模板。

希望这有帮助!!

关于azure - 如何使用 ARM 模板为 Azure 资源创建事件日志诊断设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60112639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com