3

I'm trying to write a powershell script that creates a new streamAnalytics job in my azure portal account, with input source as iot-hub and output source as blob storage account.

To do so, I'm using AzureRM command new-streamAnalyticsJob, and json files.

my problem is: I have not seen any documentation or example for json file where the inputs source is iot-hub. only event-hub.

what are the parameters I need to give in the json file? can anyone display an example for json file with input source to streamAnalytics job as Iot-hub?

N.avraham
  • 333
  • 2
  • 15

3 Answers3

2

I got the answer eventually: the required field I had to add to the inputs Oliver posted earlier here is:
"endpoint":"messages/events" I added it under Datasource Properties section, and it works fine!

Thanks Oliver

N.avraham
  • 333
  • 2
  • 15
1

That'd look like the following for the inputs part of the ASA resource:

"Inputs": [
      {
        "Name": "IoTHubStream",
        "Properties": {
          "DataSource": {
            "Properties": {
              "consumerGroupName": "[variables('CGName')]",
              "iotHubNamespace": "[variables('iotHubName')]",
              "sharedAccessPolicyKey": "[listkeys(variables('iotHubKeyResource'), variables('iotHubVersion')).primaryKey]",
              "sharedAccessPolicyName": "[variables('iotHubKeyName')]"
            },
            "Type": "Microsoft.Devices/IotHubs"
          },
          "Serialization": {
            "Properties": {
              "Encoding": "UTF8"
            },
            "Type": "Json"
          },
          "Type": "Stream"
        }
      }
    ]
SHR
  • 7,940
  • 9
  • 38
  • 57
Olivier Bloch
  • 662
  • 4
  • 7
  • Thank you, I tried this inputs, unfortunately powershell returnes me this error message: "the required property "endpoint" is missing from the request". seems that 'endpoint' field is required, but what should be it's value? – N.avraham Jun 02 '17 at 15:26
1

To come back on the error message you are seeing, to add to Olivier's sample you need a Property named endpoint which corresponds to the endpoint in IoT Hub. If you are looking for Telemetry messages this will be: "endpoint": "messages/events" This can be found in the schema for Azure ARM: https://github.com/Azure/azure-rest-api-specs/blob/current/specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/2016-03-01/examples/Input_Create_Stream_IoTHub_Avro.json

So to complete Olivier's example, when using API version '':

 "Inputs": [
                {
                    "Name": "Hub",
                    "Properties": {
                        "DataSource": {
                            "Properties": {
                                "consumerGroupName": "[variables('asaConsumerGroup')]",
                                "iotHubNamespace": "[parameters('iotHubName')]",
                                "sharedAccessPolicyKey": "[listkeys(variables('iotHubKeyResource'), variables('iotHubVersion')).primaryKey]",
                                "sharedAccessPolicyName": "[variables('iotHubKeyName')]",
                                "endpoint": "messages/events"
                            },
                            "Type": "Microsoft.Devices/IotHubs"
                        },
                        "Serialization": {
                            "Properties": {
                                "Encoding": "UTF8"
                            },
                            "Type": "Json"
                        },
                        "Type": "Stream"
                    }
                }
            ],