Skip to content

Commit 8e7549a

Browse files
authored
Merge pull request #108885 from mamccrea/asa-fraud
Stream Analytics: remove image
2 parents 7a6bc3c + 0063888 commit 8e7549a

File tree

2 files changed

+59
-51
lines changed

2 files changed

+59
-51
lines changed

articles/stream-analytics/stream-analytics-real-time-fraud-detection.md

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: mamccrea
66
ms.reviewer: mamccrea
77
ms.service: stream-analytics
88
ms.topic: conceptual
9-
ms.date: 12/07/2018
9+
ms.date: 03/24/2020
1010
ms.custom: seodec18
1111
---
1212
# Get started using Azure Stream Analytics: Real-time fraud detection
@@ -63,7 +63,7 @@ In this procedure, you first create an event hub namespace, and then you add an
6363

6464
5. Select a subscription and create or choose a resource group, then click **Create**.
6565

66-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-eventhub-namespace-new-portal.png" alt="Create event hub namespace in Azure portal" width="300px"/>
66+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-eventhub-namespace-new-portal.png" alt="Create event hub namespace in Azure portal" width="300px"/>
6767

6868
6. When the namespace has finished deploying, find the event hub namespace in your list of Azure resources.
6969

@@ -73,41 +73,42 @@ In this procedure, you first create an event hub namespace, and then you add an
7373

7474
8. Name the new event hub `asa-eh-frauddetection-demo`. You can use a different name. If you do, make a note of it, because you need the name later. You don't need to set any other options for the event hub right now.
7575

76-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-eventhub-new-portal.png" alt="Name event hub in Azure portal" width="400px"/>
76+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-eventhub-new-portal.png" alt="Name event hub in Azure portal" width="400px"/>
7777

7878
9. Click **Create**.
7979

8080
### Grant access to the event hub and get a connection string
8181

8282
Before a process can send data to an event hub, the event hub must have a policy that allows appropriate access. The access policy produces a connection string that includes authorization information.
8383

84-
1. In the event namespace pane, click **Event Hubs** and then click the name of your new event hub.
84+
1. In the event namespace pane, click **Event Hubs** and then click the name of your new event hub.
8585

86-
2. In the event hub pane, click **Shared access policies** and then click **+&nbsp;Add**.
86+
2. In the event hub pane, click **Shared access policies** and then click **+&nbsp;Add**.
8787

88-
>[!NOTE]
89-
>Make sure you're working with the event hub, not the event hub namespace.
88+
> [!NOTE]
89+
> Make sure you're working with the event hub, not the event hub namespace.
9090
91-
3. Add a policy named `asa-policy-manage-demo` and for **Claim**, select **Manage**.
91+
3. Add a policy named `asa-policy-manage-demo` and for **Claim**, select **Manage**.
9292

93-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-shared-access-policy-manage-new-portal.png" alt="Create shared access policy for Stream Analytics" width="300px"/>
93+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-shared-access-policy-manage-new-portal.png" alt="Create shared access policy for Stream Analytics" width="300px"/>
9494

95-
4. Click **Create**.
95+
4. Click **Create**.
9696

97-
5. After the policy has been deployed, click it in the list of shared access policies.
97+
5. After the policy has been deployed, click it in the list of shared access policies.
9898

99-
6. Find the box labeled **CONNECTION STRING-PRIMARY KEY** and click the copy button next to the connection string.
99+
6. Find the box labeled **CONNECTION STRING-PRIMARY KEY** and click the copy button next to the connection string.
100100

101-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-shared-access-policy-copy-connection-string-new-portal.png" alt="Stream Analytics shared access policy" width="300px"/>
101+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-shared-access-policy-copy-connection-string-new-portal.png" alt="Stream Analytics shared access policy" width="300px"/>
102102

103-
7. Paste the connection string into a text editor. You need this connection string for the next section, after you make some small edits to it.
103+
7. Paste the connection string into a text editor. You need this connection string for the next section, after you make some small edits to it.
104104

105105
The connection string looks like this:
106106

107-
Endpoint=sb://YOURNAME-eh-ns-demo.servicebus.windows.net/;SharedAccessKeyName=asa-policy-manage-demo;SharedAccessKey=Gw2NFZwU1Di+rxA2T+6hJYAtFExKRXaC2oSQa0ZsPkI=;EntityPath=asa-eh-frauddetection-demo
107+
`Endpoint=sb://YOURNAME-eh-ns-demo.servicebus.windows.net/;SharedAccessKeyName=asa-policy-manage-demo;SharedAccessKey=Gw2NFZwU1Di+rxA2T+6hJYAtFExKRXaC2oSQa0ZsPkI=;EntityPath=asa-eh-frauddetection-demo`
108108

109109
Notice that the connection string contains multiple key-value pairs, separated with semicolons: `Endpoint`, `SharedAccessKeyName`, `SharedAccessKey`, and `EntityPath`.
110110

111+
111112
## Configure and start the event generator application
112113

113114
Before you start the TelcoGenerator app, you must configure it so that it will send call records to the event hub you created.
@@ -123,20 +124,27 @@ Before you start the TelcoGenerator app, you must configure it so that it will s
123124
* Set the value of the `EventHubName` key to the event hub name (that is, to the value of the entity path).
124125
* Set the value of the `Microsoft.ServiceBus.ConnectionString` key to the connection string.
125126

126-
The `<appSettings>` section will look like the following example. (For clarity, the lines are wrapped and some characters have been removed from the authorization token.)
127+
The `<appSettings>` section will look like the following example:
127128

128-
![TelcoGenerator config file shows event hub name and connection string](./media/stream-analytics-real-time-fraud-detection/stream-analytics-telcogenerator-config-file-app-settings.png)
129+
```xml
130+
<appSettings>
131+
<!-- Service Bus specific app setings for messaging connections -->
132+
<add key="EventHubName" value="asa-eh-ns-demo"/>
133+
<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://asa-eh-ns-demo.servicebus.windows.net/;SharedAccessKeyName=asa-policy-manage-demo;SharedAccessKey=GEcnTKf2//1MRn6SN1A2u0O76MP9pj3v0Ccyf1su4Zo="/>
134+
</appSettings>
135+
```
129136

130137
4. Save the file.
131138

132139
### Start the app
133-
1. Open a command window and change to the folder where the TelcoGenerator app is unzipped.
134140

135-
2. Enter the following command:
141+
1. Open a command window and change to the folder where the TelcoGenerator app is unzipped.
136142

137-
```cmd
138-
telcodatagen.exe 1000 0.2 2
139-
```
143+
2. Enter the following command:
144+
145+
```console
146+
telcodatagen.exe 1000 0.2 2
147+
```
140148

141149
The parameters are:
142150

@@ -170,7 +178,7 @@ Now that you have a stream of call events, you can set up a Stream Analytics job
170178

171179
It's a good idea to 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.
172180

173-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-sa-job-new-portal.png" alt="Create Stream Analytics job in portal" width="300px"/>
181+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-create-sa-job-new-portal.png" alt="Create Stream Analytics job in portal" width="300px"/>
174182

175183
3. Click **Create**.
176184

@@ -187,7 +195,7 @@ Now that you have a stream of call events, you can set up a Stream Analytics job
187195

188196
|**Setting** |**Suggested value** |**Description** |
189197
|---------|---------|---------|
190-
|Input alias | CallStream | Enter a name to identify the jobs input. |
198+
|Input alias | CallStream | Enter a name to identify the job's input. |
191199
|Subscription | \<Your subscription\> | Select the Azure subscription that has the Event Hub you created. |
192200
|Event Hub namespace | asa-eh-ns-demo | Enter the name of the Event Hub namespace. |
193201
|Event Hub name | asa-eh-frauddetection-demo | Select the name of your Event Hub. |
@@ -263,11 +271,11 @@ In many cases, your analysis doesn't need all the columns from the input stream.
263271

264272
1. Change the query in the code editor to the following:
265273

266-
```SQL
267-
SELECT CallRecTime, SwitchNum, CallingIMSI, CallingNum, CalledNum
268-
FROM
269-
CallStream
270-
```
274+
```SQL
275+
SELECT CallRecTime, SwitchNum, CallingIMSI, CallingNum, CalledNum
276+
FROM
277+
CallStream
278+
```
271279

272280
2. Click **Test** again.
273281

@@ -281,13 +289,13 @@ For this transformation, you want a sequence of temporal windows that don't over
281289
282290
1. Change the query in the code editor to the following:
283291
284-
```SQL
285-
SELECT
286-
System.Timestamp as WindowEnd, SwitchNum, COUNT(*) as CallCount
287-
FROM
288-
CallStream TIMESTAMP BY CallRecTime
289-
GROUP BY TUMBLINGWINDOW(s, 5), SwitchNum
290-
```
292+
```SQL
293+
SELECT
294+
System.Timestamp as WindowEnd, SwitchNum, COUNT(*) as CallCount
295+
FROM
296+
CallStream TIMESTAMP BY CallRecTime
297+
GROUP BY TUMBLINGWINDOW(s, 5), SwitchNum
298+
```
291299
292300
This query uses the `Timestamp By` keyword in the `FROM` clause to specify which timestamp field in the input stream to use to define the Tumbling window. In this case, the window divides the data into segments by the `CallRecTime` field in each record. (If no field is specified, the windowing operation uses the time that each event arrives at the event hub. See "Arrival Time Vs Application Time" in [Stream Analytics Query Language Reference](https://docs.microsoft.com/stream-analytics-query/stream-analytics-query-language-reference).
293301
@@ -309,19 +317,19 @@ When you use a join with streaming data, the join must provide some limits on ho
309317
310318
1. Change the query in the code editor to the following:
311319
312-
```SQL
313-
SELECT System.Timestamp as Time,
314-
CS1.CallingIMSI,
315-
CS1.CallingNum as CallingNum1,
316-
CS2.CallingNum as CallingNum2,
317-
CS1.SwitchNum as Switch1,
318-
CS2.SwitchNum as Switch2
319-
FROM CallStream CS1 TIMESTAMP BY CallRecTime
320-
JOIN CallStream CS2 TIMESTAMP BY CallRecTime
321-
ON CS1.CallingIMSI = CS2.CallingIMSI
322-
AND DATEDIFF(ss, CS1, CS2) BETWEEN 1 AND 5
323-
WHERE CS1.SwitchNum != CS2.SwitchNum
324-
```
320+
```SQL
321+
SELECT System.Timestamp as Time,
322+
CS1.CallingIMSI,
323+
CS1.CallingNum as CallingNum1,
324+
CS2.CallingNum as CallingNum2,
325+
CS1.SwitchNum as Switch1,
326+
CS2.SwitchNum as Switch2
327+
FROM CallStream CS1 TIMESTAMP BY CallRecTime
328+
JOIN CallStream CS2 TIMESTAMP BY CallRecTime
329+
ON CS1.CallingIMSI = CS2.CallingIMSI
330+
AND DATEDIFF(ss, CS1, CS2) BETWEEN 1 AND 5
331+
WHERE CS1.SwitchNum != CS2.SwitchNum
332+
```
325333
326334
This query is like any SQL join except for the `DATEDIFF` function in the join. This version of `DATEDIFF` is specific to Streaming Analytics, and it must appear in the `ON...BETWEEN` clause. The parameters are a time unit (seconds in this example) and the aliases of the two sources for the join. This is different from the standard SQL `DATEDIFF` function.
327335
@@ -333,7 +341,7 @@ When you use a join with streaming data, the join must provide some limits on ho
333341
334342
3. Click **Save** to save the self-join query as part of the Streaming Analytics job. (It doesn't save the sample data.)
335343

336-
<img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-query-editor-save-button-new-portal.png" alt="Save Stream Analytics query in portal" width="300px"/>
344+
<br/><img src="./media/stream-analytics-real-time-fraud-detection/stream-analytics-query-editor-save-button-new-portal.png" alt="Save Stream Analytics query in portal" width="300px"/>
337345

338346
## Create an output sink to store transformed data
339347

@@ -357,7 +365,7 @@ If you have an existing blob storage account, you can use that. For this tutoria
357365

358366
|**Setting** |**Suggested value** |**Description** |
359367
|---------|---------|---------|
360-
|Output alias | CallStream-FraudulentCalls | Enter a name to identify the jobs output. |
368+
|Output alias | CallStream-FraudulentCalls | Enter a name to identify the job's output. |
361369
|Subscription | \<Your subscription\> | Select the Azure subscription that has the storage account you created. The storage account can be in the same or in a different subscription. This example assumes that you have created storage account in the same subscription. |
362370
|Storage account | asaehstorage | Enter the name of the storage account you created. |
363371
|Container | asa-fraudulentcalls-demo | Choose Create new and enter a container name. |

0 commit comments

Comments
 (0)