Defining Azure Stream Analytics iot-hub input source through Powershell

Viewed 629

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?

3 Answers

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"
                    }
                }
            ],
Related