public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); string fileName = req.Query["name"]; string result = DiskHelper.Delete(fileName); return(fileName != null ? (ActionResult) new OkObjectResult($"0.0, File delete: ({result})") : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); string fileName = req.Query["name"]; string blockSizeStr = req.Query["block"]; string mode = req.Query["mode"]; int blockSize; if (!int.TryParse(blockSizeStr, out blockSize)) { blockSize = 1024 * 10; } bool random = false; random = string.IsNullOrWhiteSpace(mode) ? false : (mode == "random"); Stopwatch sw = Stopwatch.StartNew(); int bytesWritten = DiskHelper.DiskWrite(fileName, 1024 * 100, delete: true); sw.Stop(); double writeTime = sw.Elapsed.TotalMilliseconds; sw.Reset(); sw.Start(); int bytesRead = random ? DiskHelper.DiskReadRandom(fileName, blockSize) : DiskHelper.DiskRead(fileName, blockSize); sw.Stop(); double readTime = sw.Elapsed.TotalMilliseconds; DiskHelper.Delete(fileName); return(fileName != null ? (ActionResult) new OkObjectResult($"{writeTime:n2},{readTime:n2}") : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }