Azure Functions Binding Expressions - HTTP Trigger and Blob Storage

Copper Contributor

I have been trying to follow the example in the following documentation: Azure Functions Binding Expressions and Patterns - JSON Payload using the In Portal code editor.

 

I can't get it to work and I've got a complete mental block on how to solve the issue.

 

The code compiles but when it is run, it returns:
Executed 'functionname' (Failed, Id=74bde612-9953-4a0b-8e88-e14c32f23b82, Duration=87ms)No value was provided for parameter 'req'.

Which of course it does! Because the HTTP Trigger is reading from a variable called 'info' - but the code still requires 'req' to be defined but it doesn't have a value until it is given a value!

 

Hopefully someone here can dig me out of this hole because I've now got complete code blindness and I can't see how to get this to work...

 

Just for ease, the code I've used from the Microsoft documentation example is as follows:

function.json:

{
  "bindings": [
    {
      "name": "info",
      "type": "httpTrigger",
      "direction": "in",
      "webHookType": "genericJson"
    },
    {
      "name": "blobContents",
      "type": "blob",
      "direction": "in",
      "path": "strings/{BlobName}",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "res",
      "type": "http",
      "direction": "out"
    }
  ]
}

 

run.csx:

using System.Net;
using Microsoft.Extensions.Logging;

public class BlobInfo
{
    public string BlobName { get; set; }
}
  
public static HttpResponseMessage Run(HttpRequestMessage req, BlobInfo info, string blobContents, ILogger log)
{
    if (blobContents == null) {
        return req.CreateResponse(HttpStatusCode.NotFound);
    } 

    log.LogInformation($"Processing: {info.BlobName}");

    return req.CreateResponse(HttpStatusCode.OK, new {
        data = $"{blobContents}"
    });
}

 

I know there's going to be a really simple answer to this... and I'm going to kick myself when you tell me it :smile:

0 Replies