{"id":16945364,"url":"https://github.com/felipecruz91/tweet-sentiment-analysis","last_synced_at":"2025-04-11T15:32:18.197Z","repository":{"id":38000599,"uuid":"180422537","full_name":"felipecruz91/tweet-sentiment-analysis","owner":"felipecruz91","description":"Real-time tweet sentiment analysis (positive/neutral/negative) and visualization in a .NET Core Web App.","archived":false,"fork":false,"pushed_at":"2022-12-08T04:25:54.000Z","size":13841,"stargazers_count":6,"open_issues_count":3,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T06:50:59.510Z","etag":null,"topics":["azure","azurefunctions","cosmosdb","docker","sentiment-analysis","twitter-streaming-api"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipecruz91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-09T18:01:50.000Z","updated_at":"2023-08-29T10:51:29.000Z","dependencies_parsed_at":"2023-01-25T08:30:38.420Z","dependency_job_id":null,"html_url":"https://github.com/felipecruz91/tweet-sentiment-analysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecruz91%2Ftweet-sentiment-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecruz91%2Ftweet-sentiment-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecruz91%2Ftweet-sentiment-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecruz91%2Ftweet-sentiment-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipecruz91","download_url":"https://codeload.github.com/felipecruz91/tweet-sentiment-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223472809,"owners_count":17150745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azurefunctions","cosmosdb","docker","sentiment-analysis","twitter-streaming-api"],"created_at":"2024-10-13T21:22:11.714Z","updated_at":"2024-11-07T07:04:13.947Z","avatar_url":"https://github.com/felipecruz91.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tweet Sentiment Analysis 💬➡🧠➡[😊|😐|😥]\n\n## Summary\n\n *Real-time* tweet sentiment analysis (positive/neutral/negative) and visualization in a .NET Core Web App.\n \n The tweets that are retrieved in *real-time* from the Twitter Stream will be processed and analyzed by the Azure Sentiment Analysis API and persisted in Cosmos DB. \n Finally, both the tweet text and sentiment will be displayed in the Web App as they come through.\n\n ![demo](./docs/images/demo.gif)\n\n## Index\n\n- [Architecture diagram](#architecture-diagram)\n- [Requirements](#requirements)\n- [Deploy the infrastructure to Azure](#Deploy-the-infrastructure-to-Azure)\n- [Build and push the docker image](#Build-and-push-the-docker-image)\n- [Run the docker image (locally)](#Run-the-docker-image-(locally))\n- [Run the docker image (as an Azure Container Instance)](#Run-the-docker-image-(as-an-Azure-Container-Instance))\n- [Deploy the Azure Function](#Deploy-the-Azure-Function)\n- [Host your *servereless* web app in Blob Storage](#Host-your-serverless-web-app-in-Blob-Storage)\n\n## Architecture diagram\n\n![architecture-diagram](./docs/images/architecture-diagram.PNG)\n\n## Requirements\n\nYou will need the following tools to complete the hands-on lab.\n\n- Visual Studio 2017\n- [Azure Functions Core Tools V2](https://github.com/Azure/azure-functions-core-tools#windows)\n- Docker\n- Azure account\n- Twitter App. If you don't have one, create one [here](https://developer.twitter.com/en/apps).\n\n## Deploy the infrastructure to Azure\n\nYou will be deploying the following resources to Azure using an already defined [ARM template](./arm-template/azuredeploy.json):\n\n- Container registry\n- Azure Cosmos DB\n- Application Insights\n- Function App (Consumption plan)\n- Storage Account\n- SignalR Service\n- Cognitive Services (Sentiment Analysis)\n\n![arm-infrastructure-resources](./docs/images/arm-infrastructure-resources.PNG)\n\nThe following [README](./arm-template/README.md) will guide you through the instructions to deploy all the resources aforementioned.\n\n\u003e **Important**: Before deploying the infrastructure, make sure you set your own resource names in the [parameters file](./arm-template/azuredeploy.parameters.json).\n\nIf you have chosen to deploy the resources using the Azure PowerShell module you can easily get the connection strings and keys from the PowerShell window; \n![arm-infrastructure-deployment-output](./docs/images/arm-infrastructure-deployment-output.PNG)\n\nOtherwise, you can download all the info from a zip file with the deployment details output files \"deployment.json\" and  \"deployment_operations.json\" ![deployment details output results](./docs/images/deployment-results.PNG) \n![deployment operation results](./docs/images/deployment-operation-results.PNG) \n\nNext step is to update the file [appsettings.sample.json](./TweetSentimentAnalysis.Processor/appsettings.sample.json) with your keys:\n\n    {\n        \"Twitter\": {\n            \"ConsumerKey\": \"\u003cyour-consumer-key\u003e\",\n            \"ConsumerSecret\": \"\u003cyour-consumer-secret\u003e\",\n            \"AccessToken\": \"\u003cyour-access-token\u003e\",\n            \"AccessTokenSecret\": \"\u003cyour-access-token-secret\u003e\",\n            \"Keyword\": \"\u003cyour-keyword-or-hashtag\u003e\",\n            \"TweetsPerMinute\": 3\n        },        \n        \"TextAnalytics\": {\n            \"Name\": \"\u003cyour-cognitive-service-resource-name\u003e\",\n            \"Key1\": \"\u003ccognitivekeys-key1\u003e\",\n            \"Key2\": \"\u003ccognitivekeys-key2\u003e\",\n            \"Language\": \"en\"\n        },\n        \"CosmosDB\": {\n            \"EndpointUrl\": \"\u003ccosmosDbEndpoint\u003e\",\n            \"AuthorizationKey\": \"\u003ccosmosDbPrimaryKey\u003e\"\n        }\n    }\nIn this [link](https://developer.twitter.com/en/docs/basics/apps/guides/the-app-management-dashboard) you can find how to create a Twitter App to get your Key and Token to use Twitter's Api.\n\nOnce you have done that, make sure you rename the `appsettings.sample.json` file to `appsettings.json`.\n\n## Build and push the docker image\n\nThe `TweetSentimentAnalysis.Processor` is a .NET Core App 2.2 that listens to the Twitter Stream for tweets given a `keyword` - you must set it in the `appsettings.json` file or pass it as an environment variable when you *run* the docker image.\n\n### Login to your Azure Container Registry\n\n    λ docker login \u003cyour-docker-registry\u003e -u \u003cyour-user\u003e -p \u003cyour-password\u003e\n\n    Example:\n    λ docker login acrfcz.azurecr.io -u myuser -p 1234\n\n    WARNING! Using --password via the CLI is insecure. Use --password-stdin.\n    Login Succeeded\n\n### Build and publish the docker image\n\n    λ build-and-push.cmd \u003cyour-docker-registry\u003e \u003cdocker-img-version\u003e\n\n    Example:\n    λ build-and-push.cmd acrfcz.azurecr.io 0.1.0\n\n### Run the docker image (locally)\n\n    λ docker run -it --rm -e \"Keyword=I love coding\" twitterfeedprocessor\n\n    [04/12/2019 16:15:12] - Starting program...\n    [04/12/2019 16:15:12] - Environment:\n    [04/12/2019 16:15:12] - Starting listening for tweets that contains the keyword 'I love coding'...\n\nor... \n\n### Run the docker image (as an Azure Container Instance)\n\n![run-twitterfeedprocessor-as-container-instance](./docs/images/run-twitterfeedprocessor-as-container-instance.PNG)\n\n## Deploy the Azure Function\n\nWithin Visual Studio, right click on the `TweetSentimentAnalysis.FunctionApp` project and select `Publish...`\n\n![deploy-azure-function-from-vs](./docs/images/deploy-azure-function-from-vs.PNG)\n\n\u003e TIP: If you wanted to debug the Azure Function, make a copy of the `local.settings.sample.json` file that is present in the `TweetSentimentAnalysis.FunctionApp` folder and rename it to `local.settings.json`. Then update the following values according to the resources you created:\n\n    {\n        \"IsEncrypted\": false,\n        \"Values\": {\n            \"FUNCTIONS_WORKER_RUNTIME\": \"dotnet\",\n            \"CosmosDbConnectionString\": \"\u003ccosmosdb-connection-string\u003e\",\n            \"AzureSignalRConnectionString\": \"\u003csignalr-connection-string\u003e\"\n        }\n    }\n\n## Host your *serverless* web app in Blob Storage\n\nNow it's time to build our *serverless* web app that consists of an index.html in Vue.js and with the SignalR JS libraries to interact with our backend (the Azure Function).\n\nIn the storage account, let's create a new blob container with the following configuration:\n\n- Name: `$web`\n- Public access level: `Blob (anonymous read access for blobs only)`\n\n![create-blob-containter](./docs/images/create-blob-container.PNG)\n\nThis will allow our *serverless* web app to be publicly available instead of private.\n\nThen click in the container and just upload the [index.html](./docs/demo/app/index.html) file:\n\n![upload-index](./docs/images/upload-index.PNG)\n\nYou can find your *serverless* web app URL by clicking on the blob:\n\n![web-app-url](./docs/images/web-app-url.PNG)\n\nExample:\n\n    https://safcztweetsentiment.blob.core.windows.net/$web/index.html\n\nOnce you click on it, a pop-up will appear. Enter the Azure Functionapp base URL and press OK.\n\n![webapp-popup](./docs/images/webapp-popup.PNG)\n\nSome tweets should start appearing now :)\n\n![demo](./docs/images/demo.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecruz91%2Ftweet-sentiment-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipecruz91%2Ftweet-sentiment-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecruz91%2Ftweet-sentiment-analysis/lists"}