You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/stream-analytics/stream-analytics-twitter-sentiment-analysis-trends.md
+21-32Lines changed: 21 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,26 +7,26 @@ ms.author: ebnkruma
7
7
ms.reviewer: jasonh
8
8
ms.service: stream-analytics
9
9
ms.topic: how-to
10
-
ms.date: 03/16/2021
10
+
ms.date: 10/03/2022
11
11
---
12
12
13
13
# Social media analysis with Azure Stream Analytics
14
14
15
-
This article teaches you how to build a social media sentiment analysis solution by bringing real-time Twitter events into Azure Event Hubs. You write an Azure Stream Analytics query to analyze the data and store the results for later use or create a [Power BI](https://powerbi.com/) dashboard to provide insights in real-time.
15
+
This article teaches you how to build a social media sentiment analysis solution by bringing real-time Twitter events into Azure Event Hubs and then analyzing them using Stream Analytics. You write an Azure Stream Analytics query to analyze the data and store results for later use or create a [Power BI](https://powerbi.com/) dashboard to provide insights in real-time.
16
16
17
17
Social media analytics tools help organizations understand trending topics. Trending topics are subjects and attitudes that have a high volume of posts on social media. Sentiment analysis, which is also called *opinion mining*, uses social media analytics tools to determine attitudes toward a product or idea.
18
18
19
19
Real-time Twitter trend analysis is a great example of an analytics tool because the hashtag subscription model enables you to listen to specific keywords (hashtags) and develop sentiment analysis of the feed.
20
20
21
21
## Scenario: Social media sentiment analysis in real time
22
22
23
-
A company that has a news media website is interested in gaining an advantage over its competitors by featuring site content that is immediately relevant to its readers. The company uses social media analysis on topics that are relevant to readers by doing real-time sentiment analysis of Twitter data.
23
+
A company that has a news media website is interested in gaining an advantage over its competitors by featuring site content that's immediately relevant to its readers. The company uses social media analysis on topics that are relevant to readers by doing real-time sentiment analysis of Twitter data.
24
24
25
25
To identify trending topics in real time on Twitter, the company needs real-time analytics about the tweet volume and sentiment for key topics.
26
26
27
27
## Prerequisites
28
28
29
-
In this how-to guide, you use a client application that connects to Twitter and looks for tweets that have certain hashtags (which you can set). To run the application and analyze the tweets using Azure Streaming Analytics, you must have the following:
29
+
In this how-to guide, you use a client application that connects to Twitter and looks for tweets that have certain hashtags (which you can set). The following list gives you prerequisites for running the application and analyzing the tweets using Azure Streaming Analytics.
30
30
31
31
* If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/).
32
32
@@ -36,43 +36,32 @@ In this how-to guide, you use a client application that connects to Twitter and
36
36
37
37
* Install the [.NET Core CLI](/dotnet/core/tools/?tabs=netcore2x) version 2.1.0.
38
38
39
-
Below is the solution architecture you are going to implement.
39
+
Here's the solution architecture you're going to implement.
40
40
41
41

42
42
43
43
## Create an event hub for streaming input
44
44
45
-
The sample application generates events and pushes them to an Azure event hub. Azure Event Hubs are the preferred method of event ingestion for Stream Analytics. For more information, see the [Azure Event Hubs documentation](../event-hubs/event-hubs-about.md).
45
+
The sample application generates events and pushes them to an event hub. Azure Event Hubs is the preferred method of event ingestion for Stream Analytics. For more information, see the [Azure Event Hubs documentation](../event-hubs/event-hubs-about.md).
46
46
47
-
### Create an event hub namespace and event hub
48
-
In this section, you create an event hub namespace and add an event hub to that namespace. Event hub namespaces are used to logically group related event bus instances.
49
47
50
-
1. Log in to the Azure portal and select **Create a resource**. Then. search for **Event Hubs**and select **Create**.
48
+
### Create an Event Hubs namespace and event hub
51
49
52
-
2. On the **Create Namespace** page, enter a namespace name. You can use any name for the namespace, but the name must be valid for a URL, and it must be unique across Azure.
53
-
54
-
3. Select a pricing tier and subscription, and create or choose a resource group. Then, choose a location and select **Create**.
55
-
56
-
4. When the namespace has finished deploying, navigate to your resource group and find the event hub namespace in your list of Azure resources.
57
-
58
-
5. From the new namespace, select **+ Event Hub**.
50
+
Follow instructions from [Quickstart: Create an event hub using Azure portal](../event-hubs/event-hubs-create.md) to create an Event Hubs namespace and an event hub named **socialtwitter-eh**. 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.
59
51
60
-
6. Name the new event hub *socialtwitter-eh*. 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.
61
-
62
-
7. Select **Create**.
63
52
64
53
### Grant access to the event hub
65
54
66
55
Before a process can send data to an event hub, the event hub needs a policy that allows access. The access policy produces a connection string that includes authorization information.
67
56
68
-
1. In the navigation bar on the left side of your event hubs namespace, select **Event Hubs**, which is located in the **Entities** section. Then, select the event hub you just created.
57
+
1. In the navigation bar on the left side of your Event Hubs namespace, select **Event Hubs**, which is located in the **Entities** section. Then, select the event hub you just created.
69
58
70
59
2. In the navigation bar on the left side, select **Shared access policies** located under **Settings**.
71
60
72
61
>[!NOTE]
73
-
>There is a Shared access policies option under for the event hub namespace and for the event hub. Make sure you're working in the context of your event hub, not the overall event hub namespace.
62
+
>There is a **Shared access policies** option under for the namespace and for the event hub. Make sure you're working in the context of your event hub, not the namespace.
74
63
75
-
3. From the access policy page, select **+ Add**. Then enter *socialtwitter-access* for the **Policy name** and check the **Manage** checkbox.
64
+
3. On the **Shared access policies** page, select **+ Add** on the commandbar. Then enter *socialtwitter-access* for the **Policy name** and check the **Manage** checkbox.
76
65
77
66
4. Select **Create**.
78
67
@@ -85,7 +74,7 @@ Before a process can send data to an event hub, the event hub needs a policy tha
Notice that the connection string contains multiple key-value pairs, separated with semicolons: `Endpoint`, `SharedAccessKeyName`, `SharedAccessKey`, and `EntityPath`.
@@ -98,7 +87,7 @@ Before a process can send data to an event hub, the event hub needs a policy tha
98
87
The client application gets tweet events directly from Twitter. In order to do so, it needs permission to call the Twitter Streaming APIs. To configure that permission, you create an application in Twitter, which generates unique credentials (such as an OAuth token). You can then configure the client application to use these credentials when it makes API calls.
99
88
100
89
### Create a Twitter application
101
-
If you do not already have a Twitter application that you can use for this how-to guide, you can create one. You must already have a Twitter account.
90
+
If you don't already have a Twitter application that you can use for this how-to guide, you can create one. You must already have a Twitter account.
102
91
103
92
> [!NOTE]
104
93
> The exact process in Twitter for creating an application and getting the keys, secrets, and token might change. If these instructions don't match what you see on the Twitter site, refer to the Twitter developer documentation.
@@ -135,7 +124,7 @@ Before the application runs, it requires certain information from you, like the
135
124
* Set `EventHubNameConnectionString` to the connection string.
136
125
* Set `EventHubName` to the event hub name (that is the value of the entity path).
137
126
138
-
3. Open the command line and navigate to the directory where your TwitterClientCore app is located. Use the command `dotnet build` to build the project. Then use the command `dotnet run` to run the app. The app sends Tweets to your Event Hub.
127
+
3. Open the command line and navigate to the directory where your TwitterClientCore app is located. Use the command `dotnet build` to build the project. Then use the command `dotnet run` to run the app. The app sends Tweets to your Event Hubs.
139
128
140
129
## Create a Stream Analytics job
141
130
@@ -159,9 +148,9 @@ Now that tweet events are streaming in real time from Twitter, you can set up a
159
148
|---------|---------|---------|
160
149
|Input alias|*TwitterStream*| Enter an alias for the input. |
161
150
|Subscription |\<Your subscription\>| Select the Azure subscription that you want to use. |
162
-
|Event Hub namespace |*asa-twitter-eventhub*|
163
-
|Event Hub name |*socialtwitter-eh*| Choose *Use existing*. Then select the Event Hub you created.|
164
-
|Event compression type|GZip| The data compression type.|
151
+
|Event Hubs namespace |*asa-twitter-eventhub*|
152
+
|Event hub name |*socialtwitter-eh*| Choose *Use existing*. Then select the event hub you created.|
153
+
|Event compression type|Gzip| The data compression type.|
165
154
166
155
Leave the remaining default values and select **Save**.
167
156
@@ -180,7 +169,7 @@ To compare the number of mentions among topics, you can use a [Tumbling window](
180
169
FROM TwitterStream
181
170
```
182
171
183
-
3. Event data from the messages should appear in the **Input preview** window below your query. Ensure the **View** is set to **JSON**. If you do not see any data, ensure that your data generator is sending events to your event hub, and that you've selected **GZip** as the compression type for the input.
172
+
3. Event data from the messages should appear in the **Input preview** window below your query. Ensure the **View** is set to **JSON**. If you don't see any data, ensure that your data generator is sending events to your event hub, and that you've selected **Gzip** as the compression type for the input.
184
173
185
174
4. Select **Test query** and notice the results in the **Test results** window below your query.
186
175
@@ -196,15 +185,15 @@ To compare the number of mentions among topics, you can use a [Tumbling window](
196
185
197
186
## Create an output sink
198
187
199
-
You have now defined an event stream, an event hub input to ingest events, and a query to perform a transformation over the stream. The last step is to define an output sink for the job.
188
+
You've now defined an event stream, an event hub input to ingest events, and a query to perform a transformation over the stream. The last step is to define an output sink for the job.
200
189
201
190
In this how-to guide, you write the aggregated tweet events from the job query to Azure Blob storage. You can also push your results to Azure SQL Database, Azure Table storage, Event Hubs, or Power BI, depending on your application needs.
202
191
203
192
## Specify the job output
204
193
205
194
1. Under the **Job Topology** section on the left navigation menu, select **Outputs**.
206
195
207
-
2. In the **Outputs** page, click**+ Add** and **Blob storage/Data Lake Storage Gen2**:
196
+
2. In the **Outputs** page, select**+ Add** and **Blob storage/Data Lake Storage Gen2**:
208
197
209
198
***Output alias**: Use the name `TwitterStream-Output`.
210
199
***Import options**: Select **Select storage from your subscriptions**.
@@ -215,7 +204,7 @@ In this how-to guide, you write the aggregated tweet events from the job query t
215
204
216
205
## Start the job
217
206
218
-
A job input, query, and output are specified. You are ready to start the Stream Analytics job.
207
+
A job input, query, and output are specified. You're ready to start the Stream Analytics job.
219
208
220
209
1. Make sure the TwitterClientCore application is running.
0 commit comments