Function code

Let's take a look at the following steps to create the function code:

  1. In the project tree, browse to the ScoreDocument.cs file.
  2. Let's replace the generated code with the following code.

The following function code assumes that the uploaded file is a text file that can be processed using StreamReader. Upon execution, the file content will be stored in the blobContent variable, while the file name will be stored in the name parameter. (The code is kept short for clarity. In production code, we would also need to perform input validation).

The code is as follows:

        public static class ScoreDocument        {          [FunctionName("ScoreDocument")]           public static async Task Run(               [BlobTrigger("documents/{name}", Connection =    "blobStorageConnection")] ...

Get Serverless computing in Azure with .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.