# Use Azure Logic Apps and Cosmos DB to monitor and archive Twitter hashtags

I love data and use it constantly to improve everything in my personal life as well as my professional life. As we are about to begin the Microsoft Ignite conference, I wanted to collect tweets that use the #MSIgnite hashtag and save them to a database. I also don't want to code as I'm working on 3 sessions right now. Here's how I did it.

# Create an Cosmos DB instance

Inside of the Azure Portal, create a Cosmos DB instance.

For Cosmos DB :

  • Use SQL for the API
  • For Database ID use cosmosdb-ignite
  • For Collection ID use items
  • Throughput use 400

# Create an Logic App instance

Inside of the Azure Portal, create a Logic App instance per the screenshot below

# Logic App Designer

Open the Logic App that you just created and select When a new tweet is posted and log in with your Twitter credentials and select the interval and text you wish to search for. In my case I'm using #MSIgnite.

Choose an action that is Create or update document

Provide the Connection Name (anything you want) and the account you wish to use.

Fill out the following fields:

  • For Database ID use cosmosdb-ignite
  • For Collection ID use items
  • For Document use:
{
  "created": @{triggerBody()?['CreatedAtIso']},
  "id": @{triggerBody()?['TweetId']},
  "text": @{triggerBody()?['TweetText']},
  "user": "@{triggerBody()?['TweetedBy']}"
}
1
2
3
4
5
6

Please note that these are dynamic fields, so you might not be able to copy and paste that text.

Click Save and then go into your Cosmos DB Instance and you can query the database to see the data coming in.