vendredi 4 juillet 2014

Azure Webjobs - call method with parameter and invoke binding


Vote count:

0




I´m playing a bit more with the web Jobs sdk and I just need to call a method via a scheduler and it should write 1-n files to the storage. The good part of the WebJobs SDK is that I don´t need to include the Azure Storage SDK and everything is "binded". It works when I specify the filename, but my "WriteCustomFile" method just writes a file called "{name}"


Code:



class Program
{
static void Main(string[] args)
{
JobHost host = new JobHost();
host.Call(typeof(Program).GetMethod("WriteFile"));
host.Call(typeof(Program).GetMethod("WriteCustomFile"), new { name = "Helloworld1.txt" });
host.Call(typeof(Program).GetMethod("WriteCustomFile"), new { name = "Helloworld2.txt" });
host.Call(typeof(Program).GetMethod("WriteCustomFile"), new { name = "Helloworld3.txt" });
//host.RunAndBlock();
}

[NoAutomaticTrigger]
public static void WriteFile([Blob("container/foobar.txt")]TextWriter writer)
{
writer.WriteLine("Hello World..." + DateTime.UtcNow.ToShortDateString() + " - " + DateTime.UtcNow.ToShortTimeString());
}

[NoAutomaticTrigger]
public static void WriteCustomFile(string name, [Blob("container/{name}")] TextWriter writer)
{
writer.WriteLine("Hello World New ..." + name + ":" + DateTime.UtcNow.ToShortDateString() + " - " + DateTime.UtcNow.ToShortTimeString());
}
}


What I would like to achieve is just to call the "WriteCustomFile" with a given filename. All samples that I found are using the "Blob Input / Output" idea in mind. I found this sample, but it seems more like a hack ;) http://ift.tt/1kQ2nS2


Is there currently a way to do this?



asked 51 secs ago






Aucun commentaire:

Enregistrer un commentaire