This commit is contained in:
Luis Quintanilla 2022-12-12 13:59:20 -05:00 коммит произвёл GitHub
Родитель 46df062230
Коммит c62259615e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 33 добавлений и 17 удалений

Просмотреть файл

@ -14,7 +14,6 @@ namespace SentimentAnalysisFunctionsApp
{
public class AnalyzeSentiment
{
private readonly PredictionEnginePool<SentimentData, SentimentPrediction> _predictionEnginePool;
// AnalyzeSentiment class constructor
@ -25,12 +24,12 @@ namespace SentimentAnalysisFunctionsApp
[FunctionName("AnalyzeSentiment")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
ILogger log)
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
//Parse HTTP Request Body
// Parse HTTP Request Body
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
SentimentData data = JsonConvert.DeserializeObject<SentimentData>(requestBody);
@ -41,7 +40,7 @@ namespace SentimentAnalysisFunctionsApp
string sentiment = Convert.ToBoolean(prediction.Prediction) ? "Positive" : "Negative";
//Return Prediction
return (ActionResult)new OkObjectResult(sentiment);
return new OkObjectResult(sentiment);
}
}
}
}

Просмотреть файл

@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.ML" Version="0.15.1" />
<PackageReference Include="Microsoft.ML" Version="1.3.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.31" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.ML" Version="2.0.0" />
<PackageReference Include="Microsoft.ML" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">

Просмотреть файл

@ -1,9 +1,10 @@
using System;
using System.IO;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.ML;
using SentimentAnalysisFunctionsApp;
using SentimentAnalysisFunctionsApp.DataModels;
using System.IO;
using System;
[assembly: FunctionsStartup(typeof(Startup))]
namespace SentimentAnalysisFunctionsApp
@ -34,4 +35,4 @@ namespace SentimentAnalysisFunctionsApp
.FromFile(modelName: "SentimentAnalysisModel", filePath: _modelPath, watchForChanges: true);
}
}
}
}

Просмотреть файл

@ -1,3 +1,11 @@
{
"version": "2.0"
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}