You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建用于REST API数据Ingestion的Azure DCR失败求助

DCR创建失败的原因分析与修正方案

核心错误原因

  • 数据源配置冗余且格式违规:
    你在logsIngestion数据源中额外配置了endpoint、method、headers,这些属于客户端调用Logs Ingestion API时的请求参数,并非DCR本身的配置项,会触发Payload校验失败。同时,streams的取值必须遵循Azure自定义日志规范:Custom-<你的表名>_CL,直接填写表名不符合要求。

  • Properties参数传递错误:
    你将包含location字段的完整JSON传给了New-AzResource的-Properties参数,但该参数仅需接收DCR的properties部分内容,顶层location已通过-Location参数单独指定,重复传递会导致结构错误。

  • 目标与转换映射缺失:
    目标logAnalytics节点缺少tableName字段,需明确指定要写入的自定义日志表名;转换的outputs必须与数据源的streams格式完全一致(即Custom-<你的表名>_CL)。

修正后的PowerShell代码

# 替换以下占位符为实际值
$customTableName = "YourCustomTable_CL"
$subscriptionId = "你的订阅ID"
$resourceGroupName = "你的资源组名"
$workspaceName = "你的Log Analytics工作区名"
$dcrName = "你的DCR名称"
$location = "westeurope"

$dcrProperties = @"
{
  "dataSources": {
    "logsIngestion": [
      {
        "name": "RestApiSource",
        "streams": ["$customTableName"]
      }
    ]
  },
  "destinations": {
    "logAnalytics": [
      {
        "name": "LogAnalyticsDestination",
        "workspaceResourceId": "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.OperationalInsights/workspaces/$workspaceName",
        "tableName": "$customTableName"
      }
    ]
  },
  "transformations": [
    {
      "name": "Transformation1",
      "inputs": ["RestApiSource"],
      "outputs": ["$customTableName"],
      "query": "SELECT * FROM source"
    }
  ]
}
"@

New-AzResource -ResourceGroupName $resourceGroupName `
               -ResourceType "Microsoft.Insights/dataCollectionRules" `
               -ResourceName $dcrName `
               -Location $location `
               -Properties $dcrProperties `
               -Force

额外注意事项

  • 确保自定义日志表已在Log Analytics工作区创建,表名必须以_CL结尾。
  • DCR创建完成后,需为调用API的主体(服务主体/用户)分配Monitoring Metrics Publisher角色到DCR资源,确保具备写入权限。
  • 调用Logs Ingestion API时,需使用DCR资源ID和数据流名称(即Custom-<表名>_CL),并通过Azure AD获取有效访问令牌。

内容的提问来源于stack exchange,提问作者GJ-Hardie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 21:04:56