سؤال

I'm using the new Azure WebJobs feature and have a simple trigger when a new file comes into one of by blobs:

public static void ProcessImportFile([BlobInput("importjobsdata/{name}")] TextReader input,
                                    [BlobOutput("importjobslog/log_{name}")] TextWriter writer)
{
    writer.WriteLine("Starting import file process...");

    var result = InputData(input, writer);

    var status = result == 0 ? "SUCCESS" : "FAIL";
    var message = result == 0
        ? "Import success."
        : "Import fail. " + result + " records failed to import. Check logs for details.";

    writer.WriteLine(message);
}

What I'd like to do is get the name of the file that was uploaded (ie. the {name} property in the data annotation) so that I can write that information to the writer (log) for diagnostic purposes.

However, I can't seem to find any properties of the TextReader/BlobInput that will give me this information.

I've done a little digging and it appears that the BaseStream property of the TextReader is a Microsoft.WindowsAzure.Jobs.WatchableStream object. I'm not sure if this helps track down the name or not.

How do I go about getting it?

هل كانت مفيدة؟

المحلول

the value of the name capture would be passed to arguments with that name as well. So you should be able to do that:

public static void ProcessImportFile([BlobInput("importjobsdata/{name}")] TextReader input,
                                     string name,
                                     [BlobOutput("importjobslog/log_{name}")] TextWriter writer)
{
    writer.WriteLine(name);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top