public async Task <IActionResult> DataOpsPipe( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ExecutionContext context) { log.LogInformation("GetDataOpsPipe: Starting."); string jsonResult = "OK"; string pipeName = req.Query["name"]; //string pipeName = await new StreamReader(req.Body).ReadToEndAsync(); log.LogInformation($"ExecuteDataOps: {pipeName}"); if (string.IsNullOrEmpty(pipeName)) { log.LogError("ExecuteDataOps: error, missing pipe name"); return(new BadRequestObjectResult("Missing pipe name in body")); } var headers = req.Headers; string storageAccount = headers.FirstOrDefault(x => x.Key == "azurestorageconnection").Value; if (string.IsNullOrEmpty(storageAccount)) { log.LogError("GetDataOpsPipe: error, missing azure storage account"); return(new BadRequestObjectResult("Missing azure storage account in http header")); } DataOpsRepository dops = new DataOpsRepository(storageAccount); List <PipeLine> dataOps = await dops.GetDataOpsPipe(pipeName); jsonResult = JsonConvert.SerializeObject(dataOps, Formatting.Indented); log.LogInformation($"GetDataOpsPipe: Json result = {jsonResult}."); log.LogInformation("GetDataOpsPipe: Completed."); return(new OkObjectResult(jsonResult)); }
public static async Task <IActionResult> Delete( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("DeletePipeline: Starting."); try { string storageAccount = Utilities.GetAzureStorageConnection(req.Headers, log); string name = req.Query["name"]; if (string.IsNullOrEmpty(name)) { log.LogError("DeletePipeline: error missing pipeline name"); return(new BadRequestObjectResult("Error missing pipeline name")); } if (!name.EndsWith(".txt")) { name = name + ".txt"; } log.LogInformation($"CreatePipeline: Pipe name {name}"); DataOpsRepository dops = new DataOpsRepository(storageAccount); await dops.DeletePipeline(name); } catch (Exception ex) { log.LogError($"DeletePipeline: Error creating pipeline: {ex}"); return(new BadRequestObjectResult($"Error creating pipeline: {ex}")); } string responseMessage = "OK"; log.LogInformation("DeletePipeline: Completed."); return(new OkObjectResult(responseMessage)); }
public static async Task <IActionResult> Create( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("SavePipeline: Starting."); try { string storageAccount = Utilities.GetAzureStorageConnection(req.Headers, log); string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); DataOpsPipes pipeName = JsonConvert.DeserializeObject <DataOpsPipes>(requestBody); if (pipeName == null) { log.LogError("SavePipeline: error missing pipe ops parameters"); return(new BadRequestObjectResult("Error missing pipe parameters")); } if (string.IsNullOrEmpty(pipeName.Name)) { log.LogError("SavePipeline: error missing pipeline name"); return(new BadRequestObjectResult("Error missing pipeline name")); } string name = pipeName.Name; if (!name.EndsWith(".txt")) { name = name + ".txt"; } log.LogInformation($"CreatePipeline: Pipe name {name}"); DataOpsRepository dops = new DataOpsRepository(storageAccount); await dops.SavePipeline(name, ""); } catch (Exception ex) { log.LogError($"SavePipeline: Error creating pipeline: {ex}"); return(new BadRequestObjectResult($"Error creating pipeline: {ex}")); } string responseMessage = "OK"; log.LogInformation("SavePipeline: Completed."); return(new OkObjectResult(responseMessage)); }
public async Task <IActionResult> DataOpsList( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ExecutionContext context) { log.LogInformation("GetDataOpsList: Starting."); string jsonResult = "OK"; var headers = req.Headers; string storageAccount = headers.FirstOrDefault(x => x.Key == "azurestorageconnection").Value; if (string.IsNullOrEmpty(storageAccount)) { log.LogError("GetDataOpsList: error, missing azure storage account"); return(new BadRequestObjectResult("Missing azure storage account in http header")); } DataOpsRepository dops = new DataOpsRepository(storageAccount); List <DataOpsPipes> pipes = await dops.GetDataOpsPipes(); jsonResult = JsonConvert.SerializeObject(pipes, Formatting.Indented); log.LogInformation("GetDataOpsList: Completed."); return(new OkObjectResult(jsonResult)); }