質問

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