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
            {
                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 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...." }));
            }
        }
예제 #4
0
        public static async Task Run([TimerTrigger("0 */2 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context)
        {
            Guid ExecutionId = context.InvocationId;

            if (Shared.GlobalConfigs.GetBoolConfig("EnablePrepareFrameworkTasks"))
            {
                using (FrameworkRunner FR = new FrameworkRunner(log, ExecutionId))
                {
                    FrameworkRunner.FrameworkRunnerWorker worker = PrepareFrameworkTasks.PrepareFrameworkTasksCore;
                    FrameworkRunner.FrameworkRunnerResult result = FR.Invoke("PrepareFrameworkTasksHttpTrigger", worker);
                }
            }
        }
        public async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context)
        {
            Guid ExecutionId = context.InvocationId;

            if (_appOptions.Value.TimerTriggers.EnableGetADFStats)
            {
                using (FrameworkRunner FR = new FrameworkRunner(log, ExecutionId))
                {
                    FrameworkRunner.FrameworkRunnerWorker worker = GetADFActivityRuns;
                    FrameworkRunner.FrameworkRunnerResult result = FR.Invoke("GetADFActivityRunsTimerTrigger", worker);
                }
            }
        }
        public static async Task Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context)
        {
            Guid ExecutionId = context.InvocationId;

            if (Shared.GlobalConfigs.GetBoolConfig("EnableGetADFStats"))
            {
                using (FrameworkRunner FR = new FrameworkRunner(log, ExecutionId))
                {
                    FrameworkRunner.FrameworkRunnerWorker worker = GetADFStats.GetADFActivityErrors;
                    FrameworkRunner.FrameworkRunnerResult result = FR.Invoke("GetADFActivityErrorsTimerTrigger", worker);
                }
            }
        }
        public async Task Run([TimerTrigger("0 */2 * * * *")] TimerInfo myTimer, ILogger log, ExecutionContext context)
        {
            Guid ExecutionId = context.InvocationId;

            if (_appOptions.Value.TimerTriggers.EnablePrepareFrameworkTasks)
            {
                using (FrameworkRunner FR = new FrameworkRunner(log, ExecutionId))
                {
                    FrameworkRunner.FrameworkRunnerWorker worker = PrepareFrameworkTasks.PrepareFrameworkTasksCore;
                    FrameworkRunner.FrameworkRunnerResult result = FR.Invoke("PrepareFrameworkTasksHttpTrigger", worker);
                }
            }
        }
        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...." }));
            }
        }