我正在寻找在模板部署阶段启用诊断日志设置(文件级别,而不是blob)的选项。
我在Github上找到了以下example但是,它不起作用,说"Microsoft.Web/sites/logs" is not a valid option"
。
以下是我的模板的一部分:
{
"apiVersion": "2015-08-01",
"name": "logs",
"type": "config",
"location": "[resourcegroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Verbose"
}
},
"httpLogs": {
"fileSystem": {
"retentionInMb": 100,
"retentionInDays": 90,
"enabled": true
}
},
"failedRequestsTracing": {
"enabled": true
},
"detailedErrorMessages": {
"enabled": true
}
}
},
另外,我发现了following关于类似问题的讨论,但主题发起人声称这段代码在大多数情况下都能正常运行。
答案 0 :(得分:1)
如果要在部署Azure WebApp期间启用诊断日志设置。您可以使用以下演示代码来执行此操作。它在我身边正常工作。
<强> Deploy.json 强>
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string"
},
"appServicePlanName": {
"type": "string"
},
"siteLocation": {
"type": "string"
},
"workerSize": {
"type": "string",
"allowedValues": [
"0",
"1",
"2"
],
"defaultValue": "1"
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('appServicePlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('siteLocation')]",
"sku": {
"name": "S1",
"tier": "Standard",
"capacity": 1
},
"properties": {
"name": "[parameters('appServicePlanName')]"
}
},
{
"apiVersion": "2015-08-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('siteLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
],
"properties": {
"serverFarmId": "[parameters('appServicePlanName')]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "logs",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Verbose"
}
},
"httpLogs": {
"fileSystem": {
"retentionInMb": 100,
"retentionInDays": 90,
"enabled": true
}
},
"failedRequestsTracing": {
"enabled": true
},
"detailedErrorMessages": {
"enabled": true
}
}
}
]
}
]
}
<强> parameters.json 强>
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"value": "xxxxxx"
},
"appServicePlanName": {
"value": "xxxx"
},
"siteLocation": {
"value": "East US"
},
"workerSize": {
"value": "1"
}
}
}
从Azure门户进行检查。