2
votes

I'm really new to WebJobs and I'm struggling with something that would seem trivial. I have a storage account called "mydatastorage", and a container called "mydatacontainer". I have been scouring the web for a week now trying to do the following basic scenario:

I have a large number of blobs (already stored in Azure) that are html files. I have written some code that can take an html string and convert it to a TableEntity. I would then like to save the TableEntity to the table "mydatatable". It appears I can use a [Table] attribute to simplify the process of saving my entity to a table, or save it manually to the table in the method call. My problem is just getting the method signature right, and then how to get blobs feeding into that method. I'm somewhat confused by all the attributes like [Blob], [BlobTrigger], and types like ICollector<T> and the proper way (and when) to use them. If anyone knows of a tutorial that explains a similar situation to this one I would love to know about it.

1

1 Answers

5
votes

Try this page for information on using BlobTrigger. All our up-to-date documentation on the WebJobs SDK can be found on this main [resources page}(http://azure.microsoft.com/en-us/documentation/articles/websites-webjobs-resources).

Here is an example to point you in the right direction. You can set up a BlobTrigger to trigger when blobs are added, and you bind to your output table using TableAttribute. The ICollector<T> binding will add table entities for any instances you add to it. You can find more options on Table bindings in the above resource links. Hope this helps.

public static void ImportHtmlBlob(
    [BlobTrigger("input/{name}")] Stream input,
    string name,
    [Table("yourtable")] ICollector<YourTableType> output)
{
    ...
}