使用Python SDK创建Azure Stream Analytics作业时遇BadRequest错误
解决Azure Stream Analytics Edge作业创建时的BadRequest错误
问题原因
出现azure.core.exceptions.HttpResponseError: (BadRequest)错误,提示"请求体中的JSON无效,缺少必填属性'datasource type'",核心问题有两处:
- 输出配置的
properties中缺少必填的type字段,用于指定输出类型 - GatewayMessageBus数据源的
properties为空,缺少必填的topic属性
修复后的代码
response = client.streaming_jobs.begin_create_or_replace(resource_group_name, job_name123, streaming_job={ "location": "East US", "properties": { "sku": { "name": "standard" }, "eventsLateArrivalMaxDelayInSeconds": 1, "jobType": "edge", "inputs": [ { "name": "input", "properties": { "type": "stream", "serialization": { "type": "JSON", "properties": { "fieldDelimiter": ",", "encoding": "UTF8" } }, "datasource": { "type": "GatewayMessageBus", "properties": { "topic": "input-topic" # 添加必填的topic属性 } } } } ], "transformation": { "name": "samplequery", "properties": { "query": "select * from input" } }, "package": { "storageAccount" : { "accountName": "*******", "accountKey": "*******" }, "container": "sample" }, "outputs": [ { "name": "output", "properties": { "type": "stream", # 添加输出的必填type字段 "serialization": { "type": "JSON", "properties": { "fieldDelimiter": ",", "encoding": "UTF8" } }, "datasource": { "type": "GatewayMessageBus", "properties": { "topic": "output-topic" # 添加必填的topic属性 } } } } ] } })
关键修复说明
- 输出配置:在
outputs[0].properties下添加"type": "stream",这是输出资源的必填属性,用于标识输出为流式类型 - GatewayMessageBus数据源:给输入和输出的
datasource.properties添加topic属性,这是该类型数据源的必填配置,需根据实际业务场景指定主题名称
内容的提问来源于stack exchange,提问作者Rajiv Nekkanti
相关产品推荐
相关产品推荐

