诊断设置无法从 ARM 模板添加到“storageAccounts/blobServices”。 当我从 ARM 模板部署诊断设置时,出现以下错误。 有谁知道锄头可以解决这个问题吗? *由于公司规定,我不能使用二头肌。
错误信息
{"code":"OperationNotFound","message":"Path: '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageName}/blobServices/default/providers/Microsoft.Insights/diagnosticSettings/{storageName}-sa-blob-logs' is not supported"}
ARM 模板
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2016-09-01",
"name": "[concat(variables('StorageName'), '-sa-blob-logs')]",
"location": "[parameters('location')]",
"scope": "[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('StorageName'), 'default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('StorageName'), 'default')]"
],
"properties": {
"workspaceId": "[resourceId(variables('subscriptionId'), variables('OtherResourceGroupName'), 'Microsoft.OperationalInsights/workspaces', variables('logAnalyticsWorkSpaceName')]",
"logs": [
{
"category": "StorageWrite",
"enabled": true
}
],
"metrics": [
{
"enabled": true,
"timeGrain": "PT1M"
}
]
}
}
任何答案都会有所帮助。谢谢你。
尝试将诊断设置专门部署到
resource ID
时,由于 blobServices
格式不正确而遇到上述错误。
这里是更新的
ARM
模板,用于使用最新 API 版本为
storage accounts
blob 服务创建诊断设置:2021-05-01-preview,关注 Ms Doc 了解有关最新 API 版本的更多详细信息 .
{
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "venkatstoragedemo"
},
"settingName": {
"type": "string",
"defaultValue": "storagelogs"
},
"subscriptionId": {
"type": "string",
"defaultValue": "SUB_ID"
},
"resourceGroupName": {
"type": "string",
"defaultValue": "venkat-rg"
},
"logAnalyticsWorkSpaceName": {
"type": "string",
"defaultValue": "venkat-law"
}
},
"variables": {
"LogworkspaceResoueceId": "[resourceId(parameters('subscriptionId'), parameters('resourceGroupName'), 'Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkSpaceName'))]"
},
"resources": [
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2021-05-01-preview",
"scope": "[format('Microsoft.Storage/storageAccounts/{0}/blobServices/default', parameters('storageAccountName'))]",
"name": "[parameters('settingName')]",
"properties": {
"workspaceId": "[variables('LogworkspaceResoueceId')]",
"metrics": [
{
"category": "Transaction",
"enabled": true,
"timeGrain": "PT1M"
}
],
"logs": [
{
"category": "StorageWrite",
"enabled": true
}
]
}
}
]
}
输出
az deployment group create --resource-group "venkat-rg" --template-file "Storage.json"
运行代码后,已为存储帐户 blob 创建诊断设置。