makeporngreatagain.pro
yeahporn.top
hd xxx

Tweet Analysis using Azure Logic App, Function & Cognitive API

350
  1. Create a Cognitive Services resource
    1. Sign in to the Azure portal.
    2. Click Create a resource in the upper left-hand corner of the Azure portal.
    3. Click AI + Machine Learning > Text Analytics. Then, use the settings as specified in the table to create the resource.

      Setting Suggested value Description
      Name MyCognitiveServicesAccnt Choose a unique account name.
      Location West US Use the location nearest you.
      Pricing tier F0 Start with the lowest tier. If you run out of calls, scale to a higher tier.
      Resource group myResourceGroup Use the same resource group for all services in this tutorial.
    4. Click Create to create your resource.
    5. Click on Overview and copy the value of the Endpoint to a text editor. This value is used when creating a connection to the Cognitive Services API.
    6. In the left navigation column, click Keys, and then copy the value of Key 1 and set it aside in a text editor. You use the key to connect the logic app to your Cognitive Services API.
  2. Create the function app
    1. From the Azure portal menu or the Home page, select Create a resource.
    2. In the New page, select Compute > Function App.
    3. On the Basics page, use the function app settings as specified in the following table.
      Setting Suggested value Description
      Subscription Your subscription The subscription under which this new function app is created.
      Resource Group myResourceGroup Name for the new resource group in which to create your function app.
      Function App name Globally unique name Name that identifies your new function app. Valid characters are a-z (case insensitive), 0-9, and -.
      Publish Code Option to publish code files or a Docker container.
      Runtime stack Preferred language Choose a runtime that supports your favorite function programming language. Choose .NET Core for C# and F# functions.
      Version Version number Choose the version of your installed runtime.
      Region Preferred region Choose a region near you or near other services your functions access.

    4. Select Next : Hosting. On the Hosting page, enter the following settings.
      Setting Suggested value Description
      Storage account Globally unique name Create a storage account used by your function app. Storage account names must be between 3 and 24 characters in length and can contain numbers and lowercase letters only. You can also use an existing account, which must meet the storage account requirements.
      Operating system Preferred operating system An operating system is pre-selected for you based on your runtime stack selection, but you can change the setting if necessary.
      Plan Consumption (Serverless) Hosting plan that defines how resources are allocated to your function app. In the default Consumption plan, resources are added dynamically as required by your functions. In this serverless hosting, you pay only for the time your functions run. When you run in an App Service plan, you must manage the scaling of your function app.

    5. Select Next : Monitoring. On the Monitoring page, enter the following settings.
      Setting Suggested value Description
      Application Insights Default Creates an Application Insights resource of the same App name in the nearest supported region. By expanding this setting, you can change the New resource name or choose a different Location in an Azure geography where you want to store your data.

    6. Select Review + create to review the app configuration selections.
    7. On the Review + create page, review your settings, and then select Create to provision and deploy the function app.
    8. Select the Notification icon in the upper-right corner of the portal and watch for the Deployment succeeded message.
    9. Select Go to resource to view your new function app. You can also select Pin to dashboard. Pinning makes it easier to return to this function app resource from your dashboard.
  3. Create an HTTP triggered function
    1. Expand your function app and click the + button next to Functions. If this is the first function in your function app, select In-portal.
    2. Next, select Webhook + API and click Create.
    3. Replace the contents of the run.csx file with the following code, then click Save:
      #r "Newtonsoft.Json"
      
      using System;
      using System.Net;
      using Microsoft.AspNetCore.Mvc;
      using Microsoft.Extensions.Logging;
      using Microsoft.Extensions.Primitives;
      using Newtonsoft.Json;
      
      public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
      {
          string category = "GREEN";
      
          string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
          log.LogInformation(string.Format("The sentiment score received is '{0}'.", requestBody));
      
          double score = Convert.ToDouble(requestBody);
      
          if(score < .3)
          {
              category = "RED";
          }
          else if (score < .6) 
          {
              category = "YELLOW";
          }
      
          return requestBody != null
              ? (ActionResult)new OkObjectResult(category)
              : new BadRequestObjectResult("Please pass a value on the query string or in the request body");
      }
    4. To test the function, click Test at the far right to expand the Test tab. Type a value of 0.2 for the Request body, and then click Run. A value of RED is returned in the body of the response.
  4. Create a logic app
    1. In the Azure portal, click the Create a resource button found on the upper left-hand corner of the Azure portal.
    2. Click Web > Logic App.
    3. Then, type a value for Name like TweetSentiment, and use the settings as specified in the table.

      Setting Suggested value Description
      Name TweetSentiment Choose an appropriate name for your app.
      Resource group myResourceGroup Choose the same existing resource group as before.
      Location East US Choose a location close to you.
    4. Once you have entered the proper settings values, click Create to create your logic app.
    5. After the app is created, click your new logic app pinned to the dashboard. Then in the Logic Apps Designer, scroll down and click the Blank Logic App template.
  5. Connect to Twitter
    1. Sign in to your Twitter account and authorize Logic Apps to use your account.
    2. Use the Twitter trigger settings as specified in the table.

      Setting Suggested value Description
      Search text #Azure Use a hashtag that is popular enough to generate new tweets in the chosen interval. When using the Free tier and your hashtag is too popular, you can quickly use up the transaction quota in your Cognitive Services API.
      Interval 15 The time elapsed between Twitter requests, in frequency units.
      Frequency Minute The frequency unit used for polling Twitter.
    3. Click Save to connect to your Twitter account.
  6. Add sentiment detection
    1. Click New Step, and then Add an action.
    2. In Choose an action, type Text Analytics, and then click the Detect sentiment action.
    3. Type a connection name such as MyCognitiveServicesConnection, paste the key for your Cognitive Services API and the Cognitive Services endpoint you set aside in a text editor, and click Create.
    4. Next, enter Tweet Text in the text box and then click on New Step.
  7. Connect sentiment output to your function
    1. In the Logic Apps Designer, click New step > Add an action, filter on Azure Functions and click Choose an Azure function.
    2. Select the function app you created earlier.
    3. Select the function you created for this tutorial.
    4. In Request Body, click Score and then Save.
  8. Add email notifications
    1. In the Logic Apps Designer, click New step > Add a condition.
    2. Click Choose a value, then click Body. Select is equal to, click Choose a value and type RED, and click Save.
    3. In IF TRUE, click Add an action, search for outlook.com, click Send an email, and sign in to your Outlook.com account.
    4. In the Send an email action, use the email settings as specified in the table.
  9. Test the workflow
    1. In the Logic App Designer, click Run to start the app.
    2. In the left column, click Overview to see the status of the logic app.
    3. Click one of the runs to see details of the execution.
    4. Go to your function, view the logs, and verify that sentiment values were received and processed.
Leave A Reply

Your email address will not be published.

baseofporn.com https://www.opoptube.com
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.