Skip to content

Commit 4110431

Browse files
authored
Merge pull request #213524 from spelluru/twitter1003
A few updates, but couldn't get the twitter client app working
2 parents 844115e + 8a854b2 commit 4110431

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

articles/stream-analytics/stream-analytics-twitter-sentiment-analysis-trends.md

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ ms.author: ebnkruma
77
ms.reviewer: jasonh
88
ms.service: stream-analytics
99
ms.topic: how-to
10-
ms.date: 03/16/2021
10+
ms.date: 10/03/2022
1111
---
1212

1313
# Social media analysis with Azure Stream Analytics
1414

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.
1616

1717
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.
1818

1919
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.
2020

2121
## Scenario: Social media sentiment analysis in real time
2222

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.
2424

2525
To identify trending topics in real time on Twitter, the company needs real-time analytics about the tweet volume and sentiment for key topics.
2626

2727
## Prerequisites
2828

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.
3030

3131
* If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/).
3232

@@ -36,43 +36,32 @@ In this how-to guide, you use a client application that connects to Twitter and
3636

3737
* Install the [.NET Core CLI](/dotnet/core/tools/?tabs=netcore2x) version 2.1.0.
3838

39-
Below is the solution architecture you are going to implement.
39+
Here's the solution architecture you're going to implement.
4040

4141
![A diagram showing different pieces of services and applications used to build the solution.](./media/stream-analytics-twitter-sentiment-analysis-trends/solution-diagram.png "Solution Diagram")
4242

4343
## Create an event hub for streaming input
4444

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).
4646

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.
4947

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
5149

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.
5951

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**.
6352

6453
### Grant access to the event hub
6554

6655
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.
6756

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.
6958

7059
2. In the navigation bar on the left side, select **Shared access policies** located under **Settings**.
7160

7261
>[!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.
7463

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.
7665

7766
4. Select **Create**.
7867

@@ -85,7 +74,7 @@ Before a process can send data to an event hub, the event hub needs a policy tha
8574
The connection string looks like this:
8675

8776
```
88-
Endpoint=sb://EVENTHUBS-NAMESPACE.servicebus.windows.net/;SharedAccessKeyName=socialtwitter-access;SharedAccessKey=Gw2NFZw6r...FxKbXaC2op6a0ZsPkI=;EntityPath=socialtwitter-eh
77+
Endpoint=sb://EVENTHUBS-NAMESPACE.servicebus.windows.net/;SharedAccessKeyName=socialtwitter-access;SharedAccessKey=XXXXXXXXXXXXXXX;EntityPath=socialtwitter-eh
8978
```
9079

9180
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
9887
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.
9988

10089
### 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.
10291

10392
> [!NOTE]
10493
> 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
135124
* Set `EventHubNameConnectionString` to the connection string.
136125
* Set `EventHubName` to the event hub name (that is the value of the entity path).
137126

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.
139128

140129
## Create a Stream Analytics job
141130

@@ -159,9 +148,9 @@ Now that tweet events are streaming in real time from Twitter, you can set up a
159148
|---------|---------|---------|
160149
|Input alias| *TwitterStream* | Enter an alias for the input. |
161150
|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.|
165154

166155
Leave the remaining default values and select **Save**.
167156

@@ -180,7 +169,7 @@ To compare the number of mentions among topics, you can use a [Tumbling window](
180169
FROM TwitterStream
181170
```
182171

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.
184173

185174
4. Select **Test query** and notice the results in the **Test results** window below your query.
186175

@@ -196,15 +185,15 @@ To compare the number of mentions among topics, you can use a [Tumbling window](
196185

197186
## Create an output sink
198187

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.
200189

201190
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.
202191

203192
## Specify the job output
204193

205194
1. Under the **Job Topology** section on the left navigation menu, select **Outputs**.
206195

207-
2. In the **Outputs** page, click **+&nbsp;Add** and **Blob storage/Data Lake Storage Gen2**:
196+
2. In the **Outputs** page, select **+&nbsp;Add** and **Blob storage/Data Lake Storage Gen2**:
208197

209198
* **Output alias**: Use the name `TwitterStream-Output`.
210199
* **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
215204

216205
## Start the job
217206

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.
219208

220209
1. Make sure the TwitterClientCore application is running.
221210

0 commit comments

Comments
 (0)