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

使用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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 08:29:52