Search code examples
azure-powershellazure-stream-analyticsazure-iot-hub

New-StreamAnalyticsJob cannot create Operations Monitoring Input for an IOT Hub


We have a Stream Analytics job that has an Input mapping to an IOT Hub Operations Monitoring endpoint. We originally defined our job on the Azure Portal. It works fine when so created / updated.

We use the job logic in multiple "Azure environments" and are now keeping it in source control. We used the Visual Studio Stream Analytics Project type to manage the source code.

We are using the New-StreamAnalyticsJob Powershell command to deploy our job into different environments.

Each time we deploy, however, the resulting Stream Analytics Job's Input points to the Messaging endpoint of our IOT Hub instead of the Operations Monitoring endpoint.

Is there something we can enter into the input's JSON file to express the endpoint type? Here is the Input content of our JSON input to the cmdlet:

"Inputs": [{
                "Name": "IOT-Hub-Monitoring-By-Consumer-Group",
                "Properties": {
                    "DataSource": {
                        "Properties": {
                            "ConsumerGroupName": "theConsumerGroup",
                            "IotHubNamespace": "theIotNamespace",
                            "SharedAccessPolicyKey": null,
                            "SharedAccessPolicyName": "iothubowner"
                        },
                        "Type": "Microsoft.Devices/IotHubs"
                    },
                    "Serialization": {
                        "Properties": {
                            "Encoding": "UTF8",
                            "Format": "LineSeparated"
                        },
                        "Type": "Json"
                    },
                    "Type": "Stream"
                }
            },
            {
                "Name": "IOT-Hub-Messaging-By-Consumer-Group",
                "Properties": {
                    "DataSource": {
                        "Properties": {
                            "ConsumerGroupName": "anotherConsumerGroup",
                            "IotHubNamespace": "theIotNamespace",
                            "SharedAccessPolicyKey": null,
                            "SharedAccessPolicyName": "iothubowner"
                        },
                        "Type": "Microsoft.Devices/IotHubs"
                    },
                    "Serialization": {
                        "Properties": {
                            "Encoding": "UTF8",
                            "Format": "LineSeparated"
                        },
                        "Type": "Json"
                    },
                    "Type": "Stream"
                }
            }
        ]

Is there an endpoint element within the IotHubProperties that we're not expressing? Is it documented somewhere?


Solution

  • The suggestion from @DaveMontgomery was a good one but turned out to be not needed.

    A simple CMDLET upgrade addressed the issue.

    The root issue turned out to be that the Azure Powershell Cmdlets, up to and including version 4.1.x were using an older version of the Microsoft.Azure.Management.StreamAnalytics assembly, namely 1.0. Version 2.0 of Microsoft.Azure.Management.StreamAnalyticscame out some months ago and that release included, as I understand, adding an endpoint element to the Inputs JSON structure.

    The new CMDLETs release is documented here: https://github.com/Azure/azure-powershell/releases/tag/v4.2.0-July2017. The commits for the release included https://github.com/Azure/azure-powershell/commit/0c00632aa8f767e58077e966c04bb6fc505da1ef, which upgrades to Microsoft.Azure.Management.StreamAnalytics v2.0.

    Note that this was a beaking change, in that the JSON changed from PascalCase to camelCase.

    With this change in hand we can add an endpoint element to the Properties / DataSource /Properties IOT input, and the as-deployed Stream Analytics Jobs contains an IOT Input properly sewn to the operationsMonitoring endpoint.