| title | Event generator application |
|---|---|
| description | This include file has steps for creating an event hub, event generator application, and Stream Analytics job to analyze the data generated by the event generator application. |
| author | spelluru |
| ms.service | azure-stream-analytics |
| ms.topic | include |
| ms.date | 02/19/2026 |
| ms.author | spelluru |
Sign in to the Azure portal.
You need to send some sample data to an event hub before Stream Analytics can analyze the fraudulent calls data stream. In this tutorial, you send data to Azure by using Azure Event Hubs.
Use the following steps to create an event hub and send call data to that event hub:
-
Sign in to the Azure portal.
-
Select All services on the left menu, select Internet of things, mouse the mouse over Event Hubs, and then select + (Add) button.
:::image type="content" source="media/event-generator-app/find-event-hub-resource.png" lightbox="media/event-generator-app/find-event-hub-resource.png" alt-text="Screenshot showing the Event Hubs creation page.":::
-
On the Create Namespace page, follow these steps:
-
Select an Azure subscription where you want to create the event hub.
-
For Resource group, select Create new and enter a name for the resource group. The Event Hubs namespace is created in this resource group.
-
For Namespace name, enter a unique name for the Event Hubs namespace.
-
For Location, select the region in which you want to create the namespace.
-
For Pricing tier, select Standard.
-
Select Review + create at the bottom of the page.
:::image type="content" source="media/event-generator-app/create-event-hub-namespace.png" alt-text="Screenshot showing the Create Namespace page.":::
-
On the Review + create page of the namespace creation wizard, select Create at the bottom of the page after reviewing all settings.
-
-
After the namespace is deployed successfully, select Go to resource to navigate to the Event Hubs Namespace page.
-
On the Event Hubs namespace page, select +Event Hub on the command bar.
:::image type="content" source="media/event-generator-app/add-event-hub-button.png" alt-text="Screenshot showing the Add event hub button on the Event Hubs Namespace page.":::
-
On the Create Event Hub page, enter a Name for the event hub. Set the Partition Count to 2. Use the default options in the remaining settings and select Review + create.
:::image type="content" source="media/event-generator-app/create-event-hub-portal.png" alt-text="Screenshot showing the Create event hub page.":::
-
On the Review + create page, select Create at the bottom of the page. Then wait for the deployment to succeed.
Before an application can send data to Azure Event Hubs, the event hub must have a policy that allows access. The access policy produces a connection string that includes authorization information.
-
On the Event Hubs namespace page, select Shared access policies on the left menu.
-
Select RootManageSharedAccessKey from the list of policies.
:::image type="content" source="media/event-generator-app/select-key.png" alt-text="Screenshot that shows the Shared access policies page.":::
-
Then, select the copy button next to Connection string - primary key.
-
Paste the connection string into a text editor. You need this connection string in the next section.
The connection string looks as follows:
Endpoint=sb://<Your event hub namespace>.servicebus.windows.net/;SharedAccessKeyName=<Your shared access policy name>;SharedAccessKey=<generated key>Notice that the connection string contains multiple key-value pairs separated with semicolons: Endpoint, SharedAccessKeyName, and SharedAccessKey.
Before you start the TelcoGenerator app, you should configure it to send data to the Azure Event Hubs you created earlier.
-
Extract the contents of TelcoGenerator.zip file.
-
Open the
TelcoGenerator\TelcoGenerator\telcodatagen.exe.configfile in a text editor of your choice There's more than one.configfile, so be sure that you open the correct one. -
Update the
<appSettings>element in the config file with the following details:- Set the value of the EventHubName key to the name of the event hub you created in the previous section.
- Set the value of the Microsoft.ServiceBus.ConnectionString key to the connection string to the namespace. If you use a connection string to an event hub, not a namespace, remove
EntityPathvalue (;EntityPath=myeventhub) at the end. Don't forget to remove the semicolon that precedes the EntityPath value.
-
Save the file.
-
Next open a command window and change to the folder where you unzipped the TelcoGenerator application. Then enter the following command:
.\telcodatagen.exe 1000 0.2 2
This command takes the following parameters:
- Number of call data records per hour.
- Percentage of fraud probability, which is how often the app should simulate a fraudulent call. The value 0.2 means that about 20% of the call records look fraudulent.
- Duration in hours, which is the number of hours that the app should run. You can also stop the app at any time by ending the process (Ctrl+C) at the command line.
After a few seconds, the app starts displaying phone call records on the screen as it sends them to the event hub. The phone call data contains the following fields:
Record Definition CallrecTime The timestamp for the call start time. SwitchNum The telephone switch used to connect the call. For this example, the switches are strings that represent the country/region of origin (US, China, UK, Germany, or Australia). CallingNum The phone number of the caller. CallingIMSI The International Mobile Subscriber Identity (IMSI). It's a unique identifier of the caller. CalledNum The phone number of the call recipient. CalledIMSI International Mobile Subscriber Identity (IMSI). It's a unique identifier of the call recipient.
Now that you have a stream of call events, you can create a Stream Analytics job that reads data from the event hub.
-
To create a Stream Analytics job, navigate to the Azure portal.
-
Select All services in the left menu, search for Stream Analytics jobs, hover the mouse over the Stream Analytics jobs tile, and then select + button or select Create in the pop-up window.
:::image type="content" source="media/event-generator-app/find-stream-analytics-resource.png" alt-text="Screenshot showing how to find Stream Analytics in the Azure portal.":::
-
On the New Stream Analytics job page, follow these steps:
-
For Subscription, select the subscription that contains the Event Hubs namespace.
-
For Resource group, select the resource group you created earlier.
-
In the Instance details section, For Name, enter a unique name for the Stream Analytics job.
-
For Region, select the region in which you want to create the Stream Analytics job. We recommend that you place the job and the event hub in the same region for best performance and so that you don't pay to transfer data between regions.
-
For Hosting environment< select Cloud if it's not already selected. Stream Analytics jobs can be deployed to cloud or edge. Cloud allows you to deploy to Azure Cloud, and Edge allows you to deploy to an IoT Edge device.
-
For Streaming units, select 1. Streaming units represent the computing resources that are required to execute a job. By default, this value is set to 1. To learn about scaling streaming units, see understanding and adjusting streaming units article.
-
Select Review + create at the bottom of the page.
:::image type="content" source="media/event-generator-app/create-stream-analytics-job.png" alt-text="Screenshot that shows the Create Azure Stream Analytics job page.":::
-
-
On the Review + create page, review settings, and then select Create to create the Stream Analytics job.
-
After the job is deployed, select Go to resource to navigate to the Stream Analytics job page.
The next step is to define an input source for the job to read data using the event hub you created in the previous section.
-
On the Stream Analytics job page, in the Job Topology section on the left menu, select Inputs.
-
On the Inputs page, select + Add input and Event hub.
:::image type="content" source="media/event-generator-app/add-input-event-hub-menu.png" lightbox="media/event-generator-app/add-input-event-hub-menu.png" alt-text="Screenshot showing the Input page for a Stream Analytics job.":::
-
On the Event hub page, follow these steps:
-
For Input alias, enter CallStream. Input alias is a friendly name to identify your input. Input alias can only contain alphanumeric characters and hyphens, and must be 3-63 characters long.
-
For Subscription, select the Azure subscription where you created the event hub. The event hub can be in same or a different subscription as the Stream Analytics job.
-
For Event Hubs namespace, select the Event Hubs namespace you created in the previous section. All the namespaces available in your current subscription are listed in the dropdown.
-
For Event hub name, select the event hub you created in the previous section. All the event hubs available in the selected namespace are listed in the dropdown.
-
For Event hub consumer group, keep the Create new option selected so that a new consumer group is created on the event hub. We recommend that you use a distinct consumer group for each Stream Analytics job. If no consumer group is specified, the Stream Analytics job uses the
$Defaultconsumer group. When a job contains a self-join or has multiple inputs, some inputs later might be read by more than one reader. This situation affects the number of readers in a single consumer group. -
For Authentication mode, select Connection string. It's easier to test the tutorial with this option.
-
For Event hub policy name, select Use existing, and then select the default policy: RootManageSharedAccessKey.
-
Select Save at the bottom of the page.
:::image type="content" source="media/event-generator-app/configure-stream-analytics-input.png" alt-text="Screenshot showing the Event Hubs configuration page for an input.":::
-