我如何得到我的Azure WebJob输入blob的名字吗? [英] How do I get the name of the input blob of my Azure WebJob?
问题描述
我使用了Azure的新功能WebJobs并有一个简单的触发器,当一个新的文件进入一个由斑点:
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);
}
我想要做的就是被上传的文件(即在数据注解{name}等属性),这样我可以写信息到作家(日志)用于诊断目的的名称。
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.
不过,我似乎无法找到,这将使我这个信息的TextReader / BlobInput的任何属性。
However, I can't seem to find any properties of the TextReader/BlobInput that will give me this information.
我已经做了小挖,它看来的TextReader的BaseStream属性是Microsoft.WindowsAzure.Jobs.WatchableStream对象。我不知道如果这有助于追查名称或没有。
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.
我如何去得到它?
推荐答案
的 name的值
捕捉将被传递到的参数与该名称为好。所以,你应该能够做到这一点:
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);
}
这篇关于我如何得到我的Azure WebJob输入blob的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!