1
votes

While Passing Blob name into Azure Function, it won't able to trigger while adding message to Queue

Not Working

#r "Newtonsoft.Json"
using System;
using Newtonsoft.Json;

public static void Run(string myQueueItem, 
 Stream outputBlob, 
ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
    dynamic data = JsonConvert.DeserializeObject(myQueueItem);
    log.LogInformation($"We got a new Queue Request Type: {data.MessageType}");
    if(data.MessageType == "Create Blob")
    {
        //  outputBlob = data.Message;
    }
    // outputBlob = "";
    string blobFileName = "tettet.script";
}

Working

I want the File To be created as the queue message contain in body section.

Also need to assign the Blob File Name from Queue Object as parameter.(uploadedscript/{blobFileName})

1
A side note: Recommendation is to not use script version (.csx) of Functions but start right with pre-compiled Functions. Sooner or later you will end up there anyway ;-) stackoverflow.com/a/51404225/1537195silent
Do you have the working code?Amnesh Goel

1 Answers

0
votes

Use the code as below:

using System;

public static void Run(string myQueueItem,out string outputBlob,ILogger log)
{
    log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");

    outputBlob=myQueueItem;
}

And the function.json:

{
  "bindings": [
    {
      "name": "myQueueItem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "queue",
      "connection": "AzureWebJobsStorage"
    },
    {
      "type": "blob",
      "name": "outputBlob",
      "path": "container/{queueTrigger}",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  ]
}