public static async Task Run([TimerTrigger("0 0 14 * * *", RunOnStartup = false)] TimerInfo myTimer, ILogger log) { log.LogInformation($"Performance tests were started by timer trigger at: {DateTime.Now}"); IPerformanceRunOptionsFactory factory = new V2PerformanceRunOptionsFactory(log); PerformanceRunOptions options = await factory.CreateAsync(); await PerformanceManager.Execute(string.Empty, options, log); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { try { log.LogInformation($"Performance tests were started by http trigger at: {DateTime.Now}"); string testId = string.Empty; req.GetQueryParameterDictionary().TryGetValue("testId", out testId); if (!req.GetQueryParameterDictionary().TryGetValue("version", out string version)) { return(new BadRequestObjectResult("Specify 'version' of 'v2' or 'v3' on the query string.")); } PerformanceRunOptions options = null; switch (version.ToLowerInvariant()) { case "v2": IPerformanceRunOptionsFactory v2factory = new V2PerformanceRunOptionsFactory(log); options = await v2factory.CreateAsync(); break; case "v3": IPerformanceRunOptionsFactory v3factory = new V3PerformanceRunOptionsFactory(log); options = await v3factory.CreateAsync(); break; default: return(new BadRequestObjectResult("Specify 'version' of 'v2' or 'v3' on the query string.")); } await PerformanceManager.Execute(testId, options, log); return(new ContentResult() { Content = string.IsNullOrEmpty(testId) ? "All tests started" : $"Tests started: {testId}", ContentType = "text/html" }); } catch (Exception ex) { log.LogError(ex.ToString()); return(new ContentResult() { Content = "Exception:" + ex, ContentType = "text/html" }); } }