DenaliHardtail
DenaliHardtail

Reputation: 28306

How do I access the blob name from inside an azure function?

Given the signature below, how can I access the value of {name} inside the code block?

For a simple example, I wish to log the name of the file added to the queue. Using the signature below, I get the image stream, as expected, but I don't see a way to access the filename {name} from the stream.

    [FunctionName("Foo")]
    public static void Run([BlobTrigger("%queue%/{name}")]Stream image,
      TraceWriter log)
      {
          *** Use the value of {name} here...
      }

Upvotes: 0

Views: 1236

Answers (1)

Roman Kiss
Roman Kiss

Reputation: 8235

    [FunctionName("Foo")]
    public static void Run([BlobTrigger("%queue%/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, TraceWriter log)
    {
        log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");

        string filename = name;
        log.Info(filename);
    }

Upvotes: 3

Related Questions