我正在尝试为定义为JSON模板的Stream Analytics Job设置输出 EventHub。没有输出位,则模板已成功部署,但是在添加输出定义时,模板失败,并显示以下信息:
Deployment failed. Correlation ID: <SOME_UUID>. {
"code": "BadRequest",
"message": "The JSON provided in the request body is invalid. Property 'eventHubName' value 'parameters('eh_name')' is not acceptable.",
"details": {
"code": "400",
"message": "The JSON provided in the request body is invalid. Property 'eventHubName' value 'parameters('eh_name')' is not acceptable.",
"correlationId": "<SOME_UUID>",
"requestId": "<SOME_UUID>"
}
}
我将ARM模板定义为:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "westeurope"
},
"hubName": {
"type": "string",
"defaultValue": "fooIotHub"
},
"eh_name": {
"defaultValue": "fooEhName",
"type": "String"
},
"eh_namespace": {
"defaultValue": "fooEhNamespace",
"type": "String"
},
"streamAnalyticsJobName": {
"type": "string",
"defaultValue": "fooStreamAnalyticsJobName"
}
},
"resources": [{
"type": "Microsoft.StreamAnalytics/StreamingJobs",
"apiVersion": "2016-03-01",
"name": "[parameters('streamAnalyticsJobName')]",
"location": "[resourceGroup().location]",
"properties": {
"sku": {
"name": "standard"
},
"outputErrorPolicy": "Drop",
"eventsOutOfOrderPolicy": "adjust",
"eventsOutOfOrderMaxDelayInSeconds": 0,
"eventsLateArrivalMaxDelayInSeconds": 86400,
"inputs": [{
"Name": "IoTHubInputLable",
"Properties": {
"DataSource": {
"Properties": {
"iotHubNamespace": "[parameters('hubName')]",
"sharedAccessPolicyKey": "[listkeys(resourceId('Microsoft.Devices/IotHubs/IotHubKeys',parameters('hubName'), 'iothubowner'),'2016-02-03').primaryKey]",
"sharedAccessPolicyName": "iothubowner",
"endpoint": "messages/events"
},
"Type": "Microsoft.Devices/IotHubs"
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
},
"Type": "Stream"
}
}],
"transformation": {
"name": "Transformation",
"properties": {
"streamingUnits": 1,
"query": "<THE SQL-LIKE CODE FOR THE JOB QUERY>"
}
},
"outputs": [{
"name": "EventHubOutputLable",
"properties": {
"dataSource": {
"type": "Microsoft.ServiceBus/EventHub",
"properties": {
"eventHubName": "parameters('eh_name')",
"serviceBusNamespace": "parameters('eh_namespace')",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"serialization": {
"Properties": {
"Encoding": "UTF8"
}
}
}
}]
}
}]
}
在此处检查https://docs.microsoft.com/en-us/azure/templates/microsoft.streamanalytics/streamingjobs
看起来输出的JSON结构与预期的一样(带有properties
字段和type
)。
我已经使用开发人员工具从Chrome浏览器中找出了这些“事件中心属性”,并检查了HTTP请求“ GetOutputs”的详细信息,否则我不确定在哪里可以看到如何指定这些属性?该结构看起来与输入的IoT中心(正在运行)的结构非常相似,在这种情况下,与IoT中心详细信息相关的属性使用了不同的标签。
查看此博客帖子https://blogs.msdn.microsoft.com/david/2017/07/20/building-azure-stream-analytics-resources-via-arm-templates-part-2-the-template/
输出部分与PowerBI相关,并且属性似乎使用了不同的结构:outputPowerBISource
,所以我尝试将outputEventHubSource
字段用于Event Hub(使用Chrome浏览器进行检查)开发人员工具),而不是properties
,但出现此错误:
Deployment failed. Correlation ID: <SOME_UUID>. {
"code": "BadRequest",
"message": "The JSON provided in the request body is invalid. Required property 'properties' not found in JSON. Path '', line 1, position 1419.",
"details": {
"code": "400",
"message": "The JSON provided in the request body is invalid. Required property 'properties' not found in JSON. Path '', line 1, position 1419.",
"correlationId": "<SOME_UUID>",
"requestId": "<SOME_UUID>"
}
}
我用于部署此模板的命令是Azure CLI(来自Linux Debian计算机):
az group deployment create \
--name "deployStreamAnalyticsJobs" \
--resource-group "MyRGName" \
--template-file ./templates/stream-analytics-jobs.json
如何在Azure资源管理器(ARM)模板中为Stream Analytics作业指定输出?
答案 0 :(得分:1)
任何包含参数的属性(或任何需要求值的表达式都必须包含方括号,例如
"eventHubName": "[parameters('eh_name')]",
"serviceBusNamespace": "[parameters('eh_namespace')]",
否则将使用引号中的文字值。
有帮助吗?
答案 1 :(得分:0)
我发现所有参数都需要包裹在方括号中(如对该问题的其他回答所指出的那样)。
也要动态检索共享访问策略密钥(或事件资源中心等现有资源的任何其他参数),必须使用listKeys
和resourceId
等功能的组合,请参见下文事件中心的完整示例,描述为流分析作业的输出。
详细信息:
eventHubName
和serviceBusNamespace
定义的参数必须使用方括号进行评估(请参阅我在上面提出的问题正文中的JSON示例中如何定义这些参数)sharedAccessPolicyName
之类的硬编码字符串(或以前的参数),也可以是"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('eh_namespace'), parameters('eh_name'), 'RootManageSharedAccessKey'),'2017-04-01').primaryKey]"
使用sharedAccessPolicyKey
来动态检索的(这是敏感数据,应该受保护,避免将信息硬编码为纯字符串)以下JSON配置显示了一个现有的事件中心,该事件中心定义为为Stream Analytics Job定义的输出:
"outputs": [{
"Name": "EventHubOutputLable",
"Properties": {
"DataSource": {
"Type": "Microsoft.ServiceBus/EventHub",
"Properties": {
"eventHubName": "[parameters('eh_name')]",
"serviceBusNamespace": "[parameters('eh_namespace')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('eh_namespace'), parameters('eh_name'), 'RootManageSharedAccessKey'),'2017-04-01').primaryKey]",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
}
}
}]