c# - How to make continuous WebJob? -


i create azure webjob shown in following script dequeues item azure storage queue, , stores azure table. process finished running within 1 or 2 seconds, runs few times in minute (and halted in approximately 10 minutes). overall, not work well.

what missing? maybe i'm mixing trigger job , continuous job, hard find appropriate sample.

class program {     static void main(string[] args)     {         console.writeline("started @ {0}", datetime.now.tostring("s"));          // continuous job should have infinite loop.         while(true){             var host = new jobhost();             host.runandblock();         }     }      public static void processqueuemessage([queueinput("blogqueue")] string json)     {         var storageaccount = cloudstorageaccount.parse(configurationmanager.connectionstrings    ["storageconnectionstring"].connectionstring);         var tableclient = storageaccount.createcloudtableclient();          // store azure table storage         // omitted...          console.writeline("received json: {0}", json);     } 

a few comments:

  1. you don't need while(true) statement. runandblock has while loop inside , block there.
  2. you don't need manually retrieve table. can bind table shown in samples here
  3. you can bind storage account, don't need manually read connection string configuration file , create instance.

here example of binding storage account:

public static void processqueuemessage([queueinput("blogqueue")] string json, cloudstorageaccount)  {     ... } 

this wild guess but, code, seems storage connection string stored in storageconnectionstring in config file. jobhost expects either (1) connection strings runtime , data stored in azurejobsdata , azurejobsruntime (as described here) or (2) pass connection string parameter jobhost constructor. think reason of crash.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -