1. Packages
  2. Azure Classic
  3. How-to Guides
  4. Azure Stream Analytics

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

Azure Stream Analytics

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

View Code Deploy this example with Pulumi

An example Pulumi program that deploys an Azure Stream Analytics job to transform data in an Event Hub.

Running the App

  1. Create a new stack:

    pulumi stack init dev
    
    Copy
  2. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):

    az login
    
    Copy
  3. Restore NPM dependencies:

    npm install
    
    Copy
  4. Configure the Azure location and subscription to deploy the example to:

    pulumi config set azure:location <location>
    pulumi config set azure:subscriptionId <YOUR_SUBSCRIPTION_ID>
    
    Copy
  5. Run pulumi up to preview and deploy changes:

    $ pulumi up
    Previewing update (dev):
    ...
    
    Updating (dev):
    ...
    Resources:
      + 15 created
    Update duration: 2m43s
    
    Copy
  6. 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 curl command:

    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"}'
    
    Copy
  7. Start the Stream Analytics job. The job will start emitting messages to the output Event Hub once per minute. The Azure Function analytics-output will start printing those events into the console (you’d have to open the function console in the Azure portal to see them).

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi