Exemplo n.º 1
0
        static int Main(/*string[] args*/)
        {
            var returnError = false;

            try {
                Log.Logger = new LoggerConfiguration()
                             .MinimumLevel.Debug()
                             .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information)
                             .Enrich.FromLogContext()
                             .WriteTo.Console()
                             .CreateLogger();

                Configuration.IConfigurationProvider configurationProvider =
                    new Configuration.ConsoleConfigurationProvider();

                using (var cts = new CancellationTokenSource()) {
                    using (var deploymentExecutor = new DeploymentExecutor(configurationProvider)) {
                        try {
                            Log.Information("Starting Industrial Asset Integration Installer.");

                            deploymentExecutor.InitializeAuthenticationAsync(cts.Token).Wait();
                            deploymentExecutor.GetApplicationName();
                            deploymentExecutor.InitializeResourceGroupSelectionAsync(cts.Token).Wait();
                            deploymentExecutor.InitializeResourceManagementClients(cts.Token);
                            deploymentExecutor.RegisterResourceProvidersAsync(cts.Token).Wait();
                            deploymentExecutor.GenerateResourceNamesAsync(cts.Token).Wait();
                            deploymentExecutor.RegisterApplicationsAsync(cts.Token).Wait();
                            deploymentExecutor.CreateAzureResourcesAsync(cts.Token).Wait();

                            Log.Information("Done.");
                        }
                        catch (Exception ex) {
                            Log.Error(ex, "Failed to deploy Industrial IoT solution.");

                            deploymentExecutor.CleanupIfAskedAsync(cts.Token).Wait();
                            returnError = true;
                        }
                    }
                }
            }
            catch (Exception ex) {
                Log.Error(ex, "Unhandled exception");
                return(ERROR);
            }

            if (returnError)
            {
                return(ERROR);
            }

            return(SUCCESS);
        }
Exemplo n.º 2
0
        static int Run(IConfigurationRoot configuration)
        {
            try {
                SetupLogger();

                var appSettings           = configuration.Get <AppSettings>();
                var configurationProvider = new ConsoleConfigurationProvider(appSettings);

                using var cts = new CancellationTokenSource();
                using var deploymentExecutor = new DeploymentExecutor(configurationProvider);
                deploymentExecutor
                .RunAsync(cts.Token)
                .Wait();

                return(SUCCESS);
            }
            catch (Exception ex) {
                Log.Error(ex, "Unhandled exception");
                return(ERROR);
            }
        }