Update Az Fn Sample App (#975)
This commit is contained in:
Родитель
46df062230
Коммит
c62259615e
|
@ -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"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче