public WaitDependsOnActivity(IOptions <ARMOrchestrationOptions> options,
                              ARMTemplateHelper templateHelper,
                              IInfrastructure infrastructure)
 {
     this.options        = options?.Value;
     this.templateHelper = templateHelper;
     this.infrastructure = infrastructure;
     this.commandText    = string.Format(commandTemplate, this.options.Database.WaitDependsOnTableName);
 }
예제 #2
0
        public ARMFunctions(IOptions <ARMOrchestrationOptions> options,
                            IServiceProvider serviceProvider,
                            IInfrastructure infrastructure)
        {
            this.options         = options?.Value;
            this.serviceProvider = serviceProvider;
            this.infrastructure  = infrastructure;

            this.InitBuiltInFunction();
        }
예제 #3
0
 public WaitDependsOnWorker(
     IOrchestrationServiceClient orchestrationServiceClient,
     IOptions <ARMOrchestrationOptions> options)
 {
     this.options            = options?.Value;
     this.taskHubClient      = new TaskHubClient(orchestrationServiceClient);
     this.fetchCommandString = string.Format(fetchCommandTemplate,
                                             this.options.Database.WaitDependsOnTableName,
                                             this.options.Database.DeploymentOperationsTableName,
                                             (int)ProvisioningStage.Successed);
     this.removeCommandString = string.Format(removeCommandTemplate, this.options.Database.WaitDependsOnTableName);
 }
 public static IServiceCollection UsingARMOrchestration(this IServiceCollection services, Func <IServiceProvider, ARMOrchestrationSqlServerConfig> configOption)
 {
     services.AddSingleton((sp) =>
     {
         return(configOption(sp));
     });
     services.UsingOrchestration((sp) =>
     {
         var config = sp.GetService <ARMOrchestrationSqlServerConfig>();
         SqlServerConfiguration sqlServerConfiguration = new SqlServerConfiguration()
         {
             AutoCreate                   = config.Database.AutoCreate,
             ConnectionString             = config.Database.ConnectionString,
             HubName                      = config.Database.HubName,
             SchemaName                   = config.Database.SchemaName,
             CommunicationWorkerOptions   = config.CommunicationWorkerOptions,
             OrchestrationServiceSettings = config.OrchestrationServiceSettings
         };
         sqlServerConfiguration.OrchestrationWorkerOptions.FetchJobCount = config.OrchestrationWorkerOptions.FetchJobCount;
         sqlServerConfiguration.OrchestrationWorkerOptions.GetBuildInTaskActivitiesFromInterface = config.OrchestrationWorkerOptions.GetBuildInTaskActivitiesFromInterface;
         sqlServerConfiguration.OrchestrationWorkerOptions.GetBuildInOrchestrators = (sp) =>
         {
             IList <(string, string, Type)> orchList;
             if (config.OrchestrationWorkerOptions.GetBuildInOrchestrators == null)
             {
                 orchList = new List <(string, string, Type)>();
             }
             else
             {
                 orchList = config.OrchestrationWorkerOptions.GetBuildInOrchestrators(sp);
             }
             orchList.Add((ResourceOrchestration.Name, "1.0", typeof(ResourceOrchestration)));
             orchList.Add((DeploymentOrchestration.Name, "1.0", typeof(DeploymentOrchestration)));
             orchList.Add((RequestOrchestration.Name, "1.0", typeof(RequestOrchestration)));
             orchList.Add((CopyOrchestration.Name, "1.0", typeof(CopyOrchestration)));
             return(orchList);
         };
         sqlServerConfiguration.OrchestrationWorkerOptions.GetBuildInTaskActivities = (sp) =>
         {
             IList <(string, string, Type)> activityTypes;
             if (config.OrchestrationWorkerOptions.GetBuildInTaskActivities == null)
             {
                 activityTypes = new List <(string, string, Type)>();
             }
             else
             {
                 activityTypes = config.OrchestrationWorkerOptions.GetBuildInTaskActivities(sp);
             }
             activityTypes.Add((DeploymentOperationActivity.Name, "1.0", typeof(DeploymentOperationActivity)));
             activityTypes.Add((WaitDependsOnActivity.Name, "1.0", typeof(WaitDependsOnActivity)));
             activityTypes.Add((ValidateTemplateActivity.Name, "1.0", typeof(ValidateTemplateActivity)));
             activityTypes.Add((AsyncRequestActivity.Name, "1.0", typeof(AsyncRequestActivity)));
             activityTypes.Add((ExpandResourcePropertiesActivity.Name, "1.0", typeof(ExpandResourcePropertiesActivity)));
             return(activityTypes);
         };
         return(sqlServerConfiguration);
     });
     services.AddSingleton <ARMOrchestrationClient>();
     services.AddSingleton <ARMTemplateHelper>();
     services.AddSingleton <ARMFunctions>((sp) =>
     {
         var options = sp.GetService <IOptions <ARMOrchestrationOptions> >();
         var infra   = sp.GetService <IInfrastructure>();
         var config  = sp.GetService <ARMOrchestrationSqlServerConfig>();
         var func    = new ARMFunctions(options, sp, infra);
         config.ConfigARMFunctions?.Invoke(func);
         return(func);
     });
     services.AddSingleton <WaitDependsOnWorker>();
     services.AddSingleton <IHostedService>(p => p.GetService <WaitDependsOnWorker>());
     services.AddSingleton((sp) =>
     {
         var config = sp.GetService <ARMOrchestrationSqlServerConfig>();
         var option = new ARMOrchestrationOptions
         {
             Database = config.Database
         };
         return(Options.Create(option));
     });
     return(services);
 }