In the blog post Creating a Power BI Streaming Dataflows Solution the example C# app to send JSON messages to an Azure Event Hub was originally a Visual Studio C# Forms application. There is now another version of this application available which runs using Visual Studio Code and is a console application.

GitHub Link

Link to the C# app is here.

App Overview

The C# app generates a series of JSON messages to synthesis a user browsing an e-commerce website, viewing products, and putting products in their shopping basket. An example of the message is as follows:


App Logic

The C# app logic is as follows:

  • User Variables (provided by the user) specify the following:
    • connectingString: Endpoint=sb://<string>
    • eventHubNameWebVisits: name of event hub
    • dateValue: datetime to start messages from. E.G 2021-08-01 09:00:00
    • dateloopcounter: how many days to generate
    • minimumdailysessionblocks: set minimum randomly generated message blocks per day
    • maximumdailysessionblocks: set maximum randomly generated message blocks per day
    • minimumdailymessagesperblock: set minimum randomly generated messages per block
    • maximumdailymessagesperblock: set maximum randomly generated messages per block

For example if the following values were set:

  • dateValue: 2021-08-01 09:00:00
  • dateloopcounter: 1
  • minimumdailysessionblocks: 5
  • maximumdailysessionblocks: 10
  • minimumdailymessagesperblock: 50
  • maximumdailymessagesperblock: 100

Then the logic would:

  • Send messages for a single day
  • Generate a random number between 5 and 10 for the daily session blocks. E.G if the number was 7 then for each day there will be 7 blocks of messages sent with a time increment per block to differentiate each block
  • Generate a random number between 50 and 100 for the number of messages per block (this is generated per block loop). E.G if the number was 89 then the first block would have 89 messages. For each block (in this example 7) this random number would be re-generated.


  • Visual Studio Code (from here)
  • C# extension
  • DotNet 5.0 SDK (from here)

Changes from Original Version

  • Console application therefore no front-end form
  • Generates a single JSON message per “Web Visit”
  • Removed SessionID and replaced with UserID
  • Added SessionVIewSeconds which is a metric to show how long the user spent looking at the specific product web page
  • Added an event called putinbasket to generate a message to show a user has put a product in their basket