// Add the following message to the queue "primenumbers". // { "MinValue": 1000, "MaxValue": 1100 } public static void Create_Queue( [QueueTrigger("primenumbers")] PrimeNumbersArgs args, [Blob("primenumbers/{MinValue}-{MaxValue}", FileAccess.Write)] Stream outStream, TextWriter logger) { CreatePrimeNumbers(args, outStream, logger); }
public static void Create_Manual( IBinder binder, TextWriter logger) { var args = new PrimeNumbersArgs { MinValue = long.Parse(ConfigurationManager.AppSettings["MinValue"]), MaxValue = long.Parse(ConfigurationManager.AppSettings["MaxValue"]), }; var blobAttribute = new BlobAttribute($"primenumbers/{args.MinValue}-{args.MaxValue}", FileAccess.Write); var outStream = binder.Bind <Stream>(blobAttribute); CreatePrimeNumbers(args, outStream, logger); }
public static void CreatePrimeNumbers(PrimeNumbersArgs args, Stream outStream, TextWriter logger) { logger.WriteLine($"{DateTime.UtcNow:MM/dd HH:mm:ss.fff}: Begin"); var sleepLevel = int.Parse(ConfigurationManager.AppSettings["SleepLevel"]); var result = PrimeNumbersUtility.GetPrimeNumbers(args.MinValue, args.MaxValue); using (var writer = new StreamWriter(outStream)) { foreach (var p in result) { if (sleepLevel != 0 && p % sleepLevel == 1) { Thread.Sleep(1); } writer.Write(p); writer.Write('\n'); } } logger.WriteLine($"{DateTime.UtcNow:MM/dd HH:mm:ss.fff}: End"); }