Azure / Azure/azure-functions-core-tools

Blob trigger function F# isolated template contains a compiler error

Open
#3,453 0 comments 0 reactions 1 assignee Claimed by @khkh-ms View on GitHub
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

The default blob triggered function for F# isolated contains a compiler error.

Here are the Azure function core tools and runtime version:

```bash
% func

Azure Functions Core Tools
Core Tools Version: 4.0.5348 Commit hash: N/A (64-bit)
Function Runtime Version: 4.24.5.21262
```

After running `func new` and choosing a `BlobTrigger` function, here's the generated code for a function I named `ReadBlob`:

```fsharp
namespace Comrit.Functions

open System
open System.IO
open Microsoft.Azure.Functions.Worker
open Microsoft.Extensions.Logging

module ReadBlob =

[]
let run
(
[] myBlob: Stream,
name: string,
context: FunctionContext
) =
let logger
= context.GetLogger "ReadBlob"

use blobStreamReader
= new StreamReader(myBlob)

let blobContent
= blobStreamReader.ReadToEndAsync() |> Async.AwaitTask

let msg =
sprintf "F# Blob trigger function Processed blob\nName: %s \n Data: %s" name blobContent

logger.LogInformation msg
```

When attempting `dotnet build`, I get the following compiler error:

```
ReadBlob.fs(27,90): error FS0001: This expression was expected to have type 'string' but here has type 'Async'
```

This makes sense, since the ansychronous computation to read the blob stream was never performed. An extra operation, like `Async.RunSynchronously`, needs to be performed to actually perform the computation and read the string.

I've included screenshots of the compiler error:

Screenshot 2023-09-13 at 11 02 35 AM

Let me know if you need any additional information.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.