Setup edge hub input for azure stream analytics using the azure cli or python SDK

Rajiv 10 Reputation points
2023-08-20T21:48:11.47+00:00

I am trying to create an azure stream analytics job using azure cli or python SDK with both input and output as edge hub. I tried using None and GatewayMessageBus as the input types but both of them did not work. It gives an error message: (BadRequest) The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

Below is the example using azure cli:

 az stream-analytics input create --properties "{"type":"Stream","datasource":{"type":"GatewayMessageBus","properties":{}},"serialization":{"type":"Json","properties":{"encoding":"UTF8"}}}" --input-name "input7425" --job-name "analytics123" --resource-group "edge-analytics"

Command group 'stream-analytics' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus

(BadRequest) The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

Code: BadRequest

Message: The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

(my-new-environment) rnekkanti@Rajivs-MBP ~ % az stream-analytics input create --properties "{"type":"Stream","datasource":{"type":None,"properties":{}},"serialization":{"type":"Json","properties":{"encoding":"UTF8"}}}" --input-name "input7425" --job-name "analytics123" --resource-group "edge-analytics"

Command group 'stream-analytics' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus

(BadRequest) The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

Code: BadRequest

Message: The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

I also tried using the python sdk and it gives the same error message:

client.inputs.create_or_replace(resource_group_name, job_name123, input_name="input7970", input={
        "properties": {
           "compression": {
      "type": "None"
    },
    "datasource": {
      "properties": {},
      "type": None
    },
    "serialization": {
      "encoding": "UTF8",
      "format": None,
      "type": "Json"
    },
    "type": "Stream"
  }
},
    )


client.inputs.create_or_replace(resource_group_name, job_name123, input_name="input7970", input={
            "properties": {
                "datasource": {"properties": {"topic": "EdgeTopic1"}, "type": "GatewayMessageBus"},
                "type": "Stream",
            }
        },
    )

Getting the error message: azure.core.exceptions.HttpResponseError: (BadRequest) The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

Code: BadRequest

Message: The JSON provided in the request body is invalid. The required property 'datasource type' is missing from the request.

I tried using the azure python sdk sample and it did not work:

https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/streamanalytics/azure-mgmt-streamanalytics/generated_samples/create_a_gateway_message_bus_input.py

What is the issue here ?

Azure Stream Analytics
Azure Stream Analytics
An Azure real-time analytics service designed for mission-critical workloads.
331 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
208 questions
{count} votes