我正在通过Azure资源管理器(ARM)模板定义流分析作业。
我需要将事件中心输入中的某些消息持久保存到SQL Server数据库输出中。
运行此命令时:
az group deployment create \
--name "deployStreamAnalyticsJobs" \
--resource-group "CiTestRG" \
--template-file ./templates/stream-analytics-jobs-definition.json
然后我看到以下输出:
Deployment failed. Correlation ID: <ONE_GUID>. {
"code": "422",
"message": "The required property 'type' is missing from the request.",
"details": {
"code": "422",
"message": "The required property 'type' is missing from the request.",
"correlationId": "<ANOTHER_GUID>",
"requestId": "<YET_ANOTHER_GUID>"
}
}
我只应提供以下数据库输出详细信息:
"datasource": {
"type": "Microsoft.Sql/Server/Database",
"properties": {
"server": "string",
"database": "string",
"user": "string",
"password": "string",
"table": "string"
}
}
我认为az
命令的错误消息试图说的是那些属性未定义为string
,但是为什么文档没有指定类型而是只传递了这些属性属性作为字符串值?
这是ARM模板的JSON定义:
{
"$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": "myIoTHub"
},
"eventhubs_messages_name": {
"defaultValue": "myEhName",
"type": "String"
},
"namespaces_oecollector_name": {
"defaultValue": "myEventHub",
"type": "String"
},
"streamAnalyticsJobName": {
"type": "string",
"defaultValue": "myStreamAnalyticsJob"
}
},
"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": "EventHubOutputLable",
"Properties": {
"DataSource": {
"Type": "Microsoft.ServiceBus/EventHub",
"Properties": {
"eventHubName": "[parameters('eventhubs_messages_name')]",
"serviceBusNamespace": "[parameters('namespaces_oecollector_name')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('namespaces_oecollector_name'), parameters('eventhubs_messages_name'), 'super-user'),'2017-04-01').primaryKey]",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
}
}
}],
"outputs": [{
"Name": "myOutputDb",
"Properties": {
"DataSource": {
"Type": "Microsoft.Sql/Server/Database",
"Properties": {
"Server": "my-sql-server-name",
"Database": "my-database-name",
"User": "my-sa-user",
"Password": "my-password",
"Table": "MySchema.MyTable"
}
}
}
}],
"transformation": {
"name": "Transformation",
"properties": {
"streamingUnits": 1,
"query": "WITH data AS (\r\n SELECT\r\n <THE_FIELDS_OF_THE_JSON_INPUT_AS_COLUMNS>\r\n FROM\r\n input\r\n WHERE\r\n topic = 'FOO'\r\n )\r\n \r\n SELECT * INTO myOutputDb FROM data"
}
}
}
}]
}
如何使此Stream Analytics Job从输入事件中心中选择消息并将其存储到输出SQL Server数据库中?
答案 0 :(得分:2)
您的输入属性对象具有“数据源”和“序列化”,但缺少“类型”。没有这个,就无法知道输入是流输入还是参考数据输入。添加后,您的输入属性对象应如下所示:
"Properties": {
"type": "stream",
"DataSource": {
"Type": "Microsoft.ServiceBus/EventHub",
"Properties": {
"eventHubName": "[parameters('eventhubs_messages_name')]",
"serviceBusNamespace": "[parameters('namespaces_oecollector_name')]",
"sharedAccessPolicyKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('namespaces_oecollector_name'), parameters('eventhubs_messages_name'), 'super-user'),'2017-04-01').primaryKey]",
"sharedAccessPolicyName": "RootManageSharedAccessKey"
}
},
"Serialization": {
"Properties": {
"Encoding": "UTF8"
},
"Type": "Json"
}
}