Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Twitter Sentiment Analysis
Twitter Sentiment Analysis

Twitter Sentiment Analysis

Microsoft DevLabs

microsoft.com
|
331 installs
| (0) | Free
Gate your releases based on sentiment of tweets for a hashtag.
This extension is now unpublished from Marketplace. You can choose to uninstall it.

Twitter Sentiment Analysis Extension

This extension includes a release gate to calculate average sentiment of tweets made for a hashtag. The gate is useful to ensure that there is positivity in tweets made for the application updated on an environment before promoting the release to the next environment.

It uses Text Analytics API from Azure Cognitive Services for sentiment analysis of the tweets.

Prerequisites

Create Azure Function

The gate uses an Azure function for a server less on-demand processing of tweets received for a hashtag. Create an HTTP triggered function and use this sample code in the Azure function.

Obtain Consumer key and secret for Twitter

If you don't have twitter application, create Twitter application for using Twitter REST APIs. Once you create a twitter application, get the 'Consumer Key' and 'Consumer Secret' from 'Keys and Access Tokens' tab.

Obtain Azure Cognitive Services access key

Text Analytics API from Azure Cognitive Services is used in the sample azure function for sentiment analysis of the tweets. Cognitive service access key is required to use Text Analytics APIs. Follow this guide to obtain a cognitive service access key.

Gate

Installing the extension adds the following 'Get Twitter Sentiment' gate and agentless task.

Gate snapshot:

Gate snapshot

Input parameters

The gate required the following inputs:

  • Twitter consumer key: Specify Twitter application consumer key. To keep the value secure, define a secret variable and use it here. If you don't have twitter application, create Twitter application and get the 'Consumer Key' from 'Keys and Access Tokens' tab.

  • Twitter consumer secret: Specify Twitter application consumer secret value. To keep the value secure, define a secret variable and use it here. If you don't have twitter application, create Twitter application and get the 'Consumer Secret' from 'Keys and Access Tokens' tab.

  • Hashtag to analyze: Analyze sentiment of tweets made with this Hashtag like #ReleaseManagement.

  • Azure function url: Url of the Azure function that needs to be invoked​. Example:- https://azurefunctionapp.azurewebsites.net/api/HttpTriggerCS1.

  • Azure function key: Function or Host key with which we can access this function. To keep the key secure, define a secret variable and use it here. Example: - $(myFunctionKey) where myFunctionKey is an environment level secret variable with value as the secret key like ZxPXnIEODXLRzYwCw1TgZ4osMfoKs9Zn6se6X/N0FnztfDvZbdOmYw==.

  • Cognitive services access key: Specify access key for Text Analytics API. To keep the key secure, define a secret variable and use it here. Follow this guide to obtain a cognitive service access key.

  • Cognitive services endpoint region: Specify the region corresponding to the Text Analytics API endpoint.

  • Analyze tweets since: Analyze the tweets made after this time. By default, uses $(Release.Deployment.StartTime) and analyzes the tweets made after start of the deployment. Date and time should be in UTC and format should be yyyy-MM-ddTHH:mm:ssZ. eg. 2018-01-31T07:56:59Z

  • Threshold: Threshold value for average sentiment of the tweets analyzed. If the average sentiment score is less than the threshold, task will fail. Default value is 0.5. Threshold should be between 0 and 1.

Contact Information

You can use Azure Pipeline Extensions on Github to report any issues.

Troubleshooting

  • Why Twitter Sentiment Analysis gate is failing?
    • Check Azure function url is correct or not. Azure function url looks like https://twittersentimenttest.azurewebsites.net/api/TwitterGateFunction?code=WgAJDc/C3NRDMex5rVOev126dWx56uaaUfNx7cDRmXLfUEZdNtxM8w==. You need to specify url without 'code' parameter in Azure function url input, example:- https://twittersentimenttest.azurewebsites.net/api/TwitterGateFunction. 'code' should be specified in Azure function key input, in above example you need specify WgAJDK/C3NRXMexUrVOev319dWUuaYAaUfNx7cDRmSGfUEZdNtxM8w== in Azure function key input.

    • Check Analyze tweets since date format. Date and time should be in UTC and format should be yyyy-MM-ddTHH:mm:ssZ

    • First validate Azure function from Azure portal. You can specify parameters in 'body' section in Azure function url page like below and run Azure function to get sentiment score.

         {
           "hashTag": "ReleaseManagement",
           "consumerKey": "z3MIU6CFryAjes2jeU459oKKE",
           "consumerSecret": "J0Xp4N0epU6woYJaLM5mlUYHPGxL55qEl0nbYcXlPTafUjfRBH",
           "cognitiveServicesAccessKey": "2dbf45a2af524649a662e36c3138c156",
           "cognitiveServicesEndpointRegion": "westus2",
           "analyzeTweetsSince": "2018-01-01T07:56:59"
          }
    
      Azure function output looks like below   
         {
           "HashTag":"#ReleaseManagement",
           "Score": 0.9,
           "NumberOfTweetsParsed": 70
         }
    
    
    
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft