/// <exclude /> public static void ApplicationStartInitialize(bool displayDebugInfo = false) { ThreadDataManager.InitializeThroughHttpContext(); if (displayDebugInfo) { Log.LogVerbose("Global.asax", "--- Web Application Start, {0} Id = {1} ---", DateTime.Now.ToLongTimeString(), AppDomain.CurrentDomain.Id); } PerformanceCounterFacade.SystemStartupIncrement(); using (GlobalInitializerFacade.GetPreInitHandlersScope()) { ApplicationStartupFacade.FireConfigureServices(ServiceLocator.ServiceCollection); ServiceLocator.BuildServiceProvider(); ServiceLocator.CreateRequestServicesScope(HttpContext.Current); ApplicationStartupFacade.FireBeforeSystemInitialize(ServiceLocator.ServiceProvider); } TempDirectoryFacade.OnApplicationStart(); HostnameBindingsFacade.Initialize(); ApplicationStartupFacade.FireSystemInitialized(ServiceLocator.ServiceProvider); ThreadDataManager.FinalizeThroughHttpContext(); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage req, [Table(PARAM_TABLE, PARAM_PARTITION_KEY, PARAM_TOKEN_ROW)] Parameter parameter, [Table(PARAM_TABLE, PARAM_PARTITION_KEY)] IAsyncCollector <Parameter> tokenParameters, [Queue(TEAMS_REQUEST_QUEUE)] CloudQueue teamsRequestQueue, [Queue(USERS_REQUEST_QUEUE)] CloudQueue usersRequestQueue, [Queue(ARM_REQUEST_QUEUE)] CloudQueue armRequestQueue, ILogger log) { log.LogInformation("C# HTTP trigger function has completely processed a request."); var accessToken = req.Headers.Authorization?.Parameter; ServiceLocator.BuildServiceProvider(log, accessToken); var json = await req.Content.ReadAsStringAsync(); var jObject = JObject.Parse(json); var fileText = File.ReadAllText(@"Schemas\workflow.schema.json"); var jsonSchema = JSchema.Parse(fileText); var isValid = jObject.IsValid(jsonSchema, out IList <ValidationError> validationErrors); log.LogInformation($"C# HTTP trigger function processing a {(!isValid ? "in" : string.Empty)}valid request."); if (isValid) { var workflow = await req.Content.ReadAsAsync <Workflow>(); parameter = await CreateOrUpdateTokenParameter(parameter, tokenParameters, accessToken); foreach (var user in workflow.Users) { var requestBody = JsonConvert.SerializeObject(user); await usersRequestQueue.AddMessageAsync(new CloudQueueMessage(requestBody)); } log.LogInformation($"{workflow.Users.Count()} Users have been scheduled for creation"); // Populate arm template queue foreach (var armTemplate in workflow.ARMDeployments) { var requestBody = JsonConvert.SerializeObject(armTemplate); await armRequestQueue.AddMessageAsync(new CloudQueueMessage(requestBody)); } log.LogInformation($"{workflow.ARMDeployments.Count()} ARM Deployments have been scheduled for creation"); // Populate teams queue foreach (var team in workflow.Teams) { var requestBody = JsonConvert.SerializeObject(team); await teamsRequestQueue.AddMessageAsync(new CloudQueueMessage(requestBody)); } log.LogInformation($"{workflow.Teams.Count()} Teams has been scheduled for creation"); return(new OkObjectResult($"{workflow.Teams.Count()} Teams are scheduled for creation, {workflow.Users.Count()} Users are scheduled for creation and {workflow.ARMDeployments.Count()} ARM Deployments are scheduled for creation.")); } var errorJson = JsonConvert.SerializeObject(validationErrors); return(new BadRequestObjectResult($"Invalid HttpRequest, reason {errorJson}")); }
public static async Task Run([QueueTrigger(ARM_REQUEST_QUEUE)] ARMDeployment armDeployment, [Table(PARAM_TABLE, PARAM_PARTITION_KEY, PARAM_TOKEN_ROW)] Parameter accessToken, ILogger log) { ServiceLocator.BuildServiceProvider(log, accessToken.Value); var azureManager = ServiceLocator.GetRequiredService <IAzureManager>(); var results = await azureManager.DeployARMTemplateAsync(armDeployment); log.LogInformation($"C# Queue trigger DeployARMConfiguration processed: {armDeployment}"); log.LogInformation($"{armDeployment.Name} deployed!"); }
public static async Task Run([QueueTrigger(USERS_REQUEST_QUEUE)] UserResource userResource, [Table(PARAM_TABLE, PARAM_PARTITION_KEY, PARAM_TOKEN_ROW)] Parameter accessToken, ILogger log) { ServiceLocator.BuildServiceProvider(log, accessToken.Value); var usersManager = ServiceLocator.GetRequiredService <IUserManager>(); var results = await usersManager.CreateResourceAsync(userResource); log.LogInformation($"C# Queue trigger DeployUsersConfiguration processed: {userResource}"); log.LogInformation($"{userResource.DisplayName} user created!"); }
public static async Task Run([QueueTrigger(TEAMS_REQUEST_QUEUE)] TeamResource teamResource, [Table(PARAM_TABLE, PARAM_PARTITION_KEY, PARAM_TOKEN_ROW)] Parameter accessToken, ILogger log) { ServiceLocator.BuildServiceProvider(log, accessToken.Value); var teamsManager = ServiceLocator.GetRequiredService <ITeamsManager>(); var results = await teamsManager.CreateResourceAsync(teamResource); log.LogInformation($"C# Queue trigger DeployTeamsConfiguration processed: {teamResource}"); log.LogInformation($"{teamResource.DisplayName} team created, {teamResource.Channels.Count()} channels, {teamResource.Members.Count()} members and configurations Done!"); }