public static IActionResult Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, [Blob("models/model.zip", FileAccess.Read, Connection = "AzureWebJobsStorage")] Stream serializedModel, ILogger log) { // Workaround for Azure Functions Host /* * if (typeof(Microsoft.ML.Runtime.Data.LoadTransform) == null || * typeof(Microsoft.ML.Runtime.Learners.LinearClassificationTrainer) == null || * typeof(Microsoft.ML.Runtime.Internal.CpuMath.SseUtils) == null || * typeof(Microsoft.ML.Runtime.FastTree.FastTree) == null) * { * log.Error("Error loading ML.NET"); * return new StatusCodeResult(500); * } */ //Read incoming request body string requestBody = new StreamReader(req.Body).ReadToEnd(); log.LogInformation("C# HTTP trigger function processed a request."); log.LogInformation(requestBody); //Bind request body to IrisData object ModelInput data = JsonConvert.DeserializeObject <ModelInput>(requestBody); //Load prediction model var model = PredictionEngine.ReadAsync <ModelInput, ModelOutput>(serializedModel).Result; //Make prediction ModelOutput prediction = model.Predict(data); //Return prediction return((IActionResult) new OkObjectResult(prediction.Prediction)); }