public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context, System.Security.Claims.ClaimsPrincipal principal) { bool Allowed = false; var roles = principal.Claims.Where(e => e.Type == "roles").Select(e => e.Value); foreach (string r in roles) { if (r == "All") { Allowed = true; } } if (!Allowed && !Shared._ApplicationOptions.ServiceConnections.CoreFunctionsURL.Contains("localhost")) { string err = "Request was rejected as user is not allowed to perform this action"; log.LogError(err); return(new BadRequestObjectResult(new { Error = err })); } System.Guid ExecutionId = context.InvocationId; using FrameworkRunner FRP = new FrameworkRunner(log, ExecutionId); FrameworkRunner.FrameworkRunnerWorkerWithHttpRequest worker = StartAndStopVMsCore; FrameworkRunner.FrameworkRunnerResult result = FRP.Invoke(req, "StartAndStopVMs", worker); if (result.Succeeded) { return(new OkObjectResult(JObject.Parse(result.ReturnObject))); } else { return(new BadRequestObjectResult(new { Error = "Execution Failed...." })); } }
public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, ExecutionContext context, System.Security.Claims.ClaimsPrincipal principal) { bool IsAuthorised = _sap.IsAuthorised(req, log); if (IsAuthorised) { Guid ExecutionId = context.InvocationId; using FrameworkRunner FR = new FrameworkRunner(log, ExecutionId); FrameworkRunner.FrameworkRunnerWorkerWithHttpRequest worker = RunFrameworkTasks.RunFrameworkTasksCore; FrameworkRunner.FrameworkRunnerResult result = FR.Invoke(req, "RunFrameworkTasksHttpTrigger", worker); if (result.Succeeded) { return(new OkObjectResult(JObject.Parse(result.ReturnObject))); } else { return(new BadRequestObjectResult(new { Error = "Execution Failed...." })); } } else { return(new BadRequestObjectResult(new { Error = "User is not authorised to call this API...." })); } }
public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log, ExecutionContext context, System.Security.Claims.ClaimsPrincipal principal) { bool IsAuthorised = _sap.IsAuthorised(req, log); if (IsAuthorised) { Guid ExecutionId = context.InvocationId; using FrameworkRunner FR = new FrameworkRunner(log, ExecutionId); FrameworkRunner.FrameworkRunnerWorkerWithHttpRequest worker = RunFrameworkTasks.RunFrameworkTasksCore; FrameworkRunner.FrameworkRunnerResult result = FR.Invoke(req, "RunFrameworkTasksHttpTrigger", worker); if (result.Succeeded) { return(new OkObjectResult(JObject.Parse(result.ReturnObject))); } else { return(new BadRequestObjectResult(new { Error = "Execution Failed...." })); } } else { log.LogWarning("User is not authorised to call RunFrameworkTasksHttpTrigger."); TaskMetaDataDatabase TMD = new TaskMetaDataDatabase(); short TaskRunnerId = System.Convert.ToInt16(req.Query["TaskRunnerId"]); TMD.ExecuteSql(string.Format("exec [dbo].[UpdFrameworkTaskRunner] {0}", TaskRunnerId)); return(new BadRequestObjectResult(new { Error = "User is not authorised to call this API...." })); } }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context) { Guid ExecutionId = context.InvocationId; using FrameworkRunner FRP = new FrameworkRunner(log, ExecutionId); FrameworkRunner.FrameworkRunnerWorkerWithHttpRequest worker = SendEmailSASUri; FrameworkRunner.FrameworkRunnerResult result = FRP.Invoke(req, "GetSASUriSendEmailHttpTrigger", worker); if (result.Succeeded) { return(new OkObjectResult(JObject.Parse(result.ReturnObject))); } else { return(new BadRequestObjectResult(new { Error = "Execution Failed...." })); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, ILogger log, ExecutionContext context) { Guid ExecutionId = context.InvocationId; using FrameworkRunner FRP = new FrameworkRunner(log, ExecutionId); FrameworkRunner.FrameworkRunnerWorkerWithHttpRequest worker = CreateAzureStorageEventSubscriptionsCore; FrameworkRunner.FrameworkRunnerResult result = FRP.Invoke(req, "CreateAzureStorageEventSubscriptions", worker); if (result.Succeeded) { return(new OkObjectResult(JObject.Parse(result.ReturnObject))); } else { return(new BadRequestObjectResult(new { Error = "Execution Failed...." })); } }