Skip to content

Prozac777/ServerlessCosmosDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 

Repository files navigation

Serverless with Cosmo DB

In this demo you will create a workflow to to analyze sentiment from Twitter posts. An HTTP triggered function categorizes tweets as green, yellow, or red based on the sentiment score.

Start with the tutorial at https://docs.microsoft.com/en-us/azure/azure-functions/functions-twitter-email and work though these steps:

  1. Create a Cognitive Services account
    1. Create a new Resource Group that you will use for everything you create in this demo
    2. Location is West US
  2. Create the function
  3. Create a logic app
  4. Connect to Twitter
  5. Add sentiment detection
  6. Connect sentiment output to your function

After we connect the sentiment output with our function, we're going to save this data into Cosmos DB

Follow the first two steps at https://docs.microsoft.com/en-us/azure/cosmos-db/create-cosmosdb-resources-portal and stop at adding sample data

  1. Create a database account
  2. Create a collection

Now that the database is up...

  1. Going back into our Logic App, from the Logic App Designer, click add an action and search for Cosmos
  2. Select Create or Update document
    1. If prompted, give a connection name, then get the db Key from the Cosmos DB view in the portal
    2. Enter the database and collection
    3. Add in the JSON syntax below and use the parameters for the values shown. To make the GUID, you may have to maximize your browser window as the functionality is hidden
{  
  "id": "guid()",  
  "loc": "UserDetails.Location",  
  "score": "Body",  
  "tweet": "OriginalTweet",  
  "user": "TweetedBy"  
}  
  1. Save the Logic app
  2. Click on the first step of the Logic App, and set the interval to 1 minute
  3. Verify data is going into Cosmos by using the Data Explorer in the Cosmos Portal View

Now we will work on visualizing this data with Power BI. Download and install the desktop app from https://powerbi.microsoft.com/en-us/desktop/

We will use https://docs.microsoft.com/en-us/azure/cosmos-db/powerbi-visualize as a reference for some tasks.

  1. Start Power BI Desktop
  2. Click Get Data and select Cosmos DB
  3. From the Azure Portal, get the URL for your DB and a key for it
  4. Select the correct collection, expand the data, and then close and apply
  5. Now add a visualization, set it's properties, and test it out
  6. When you're done, click Publish. This will prompt you to save it as well
  7. Now go to https://powerbi.microsoft.com/en-us/ and log in
  8. Then you can take that report and dataset and create a dashboard

About

Demo using Logic Apps, Functions, Cosmos, and PowerBI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published