Azure Stream Analytics
Uses an Azure Stream Analytics job to transform data in an Event Hub.
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set classic-azure-ts-stream-analyticscd pulumi-examples/classic-azure-ts-stream-analyticsAn example Pulumi program that deploys an Azure Stream Analytics job to transform data in an Event Hub.
Running the App#
-
Create a new stack:
Terminal window pulumi stack init dev -
Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):
Terminal window az login -
Restore NPM dependencies:
Terminal window npm install -
Configure the Azure location and subscription to deploy the example to:
Terminal window pulumi config set azure:location <location>pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID> -
Run
pulumi upto preview and deploy changes:Terminal window pulumi upPreviewing update (dev):...Updating (dev):...Resources:+ 15 createdUpdate duration: 2m43s -
Use the following sample messages for testing:
// Inputs (1 line - 1 event):{"Make":"Kia","Sales":2,"Time":"2019-06-26T10:22:36Z"}{"Make":"Kia","Sales":1,"Time":"2019-06-26T10:22:37Z"}{"Make":"Honda","Sales":1,"Time":"2019-06-26T10:22:38Z"}// Output:[{"Make":"Kia","Sales":3};{"Make":"Honda","Sales":1}]You can send a message with a
curlcommand:Terminal window curl -X POST '$(pulumi stack output inputEndpoint)' -H 'Authorization: $(pulumi stack output sasToken)' -H 'Content-Type: application/atom+xml;type=entry;charset=utf-8' -d '{"Make":"Kia","Sales":2,"Time":"2019-06-26T10:22:36Z"}' -
Start the Stream Analytics job. The job will start emitting messages to the output Event Hub once per minute. The Azure Function
analytics-outputwill start printing those events into the console (you’d have to open the function console in the Azure portal to see them).