Exemple #1
0
        private dynamic DoDeploy(dynamic parameters)
        {
            var app = _Data.GetAppByKey((string)parameters.key);

            if (app == null)
            {
                return(Response.AsRedirect("/Apps").WithErrorFlash(Session, String.Format("App {0} not found.", (string)parameters.key)));
            }
            if (!Request.Form.application_name.HasValue)
            {
                return(Response.AsRedirect("/Deploy/" + app.Key).WithErrorFlash(Session, "Please enter an application name"));
            }
            if (!Request.Form.region_id.HasValue || !_Data.DoesRegionExist(Request.Form.region_id))
            {
                return(Response.AsRedirect("/Deploy/" + app.Key).WithErrorFlash(Session, "Please choose a valid deployment region"));
            }

            string appName   = Request.Form.application_name;
            string region_id = Request.Form.region_id;
            string slug      = "";

            // Build set of variables that need to be added to the application
            var variables = new Dictionary <string, string>();

            foreach (var variable in app.Variables)
            {
                if (Request.Form[variable.Key].HasValue)
                {
                    variables.Add(variable.Key, Request.Form[variable.Key]);
                }
            }
            foreach (var variable in app.DefaultVariables)
            {
                variables.Add(variable.Key, this.ParseDefaultValue(variable.Value));
            }

            var result = _Deploy.Deploy(appName, region_id, app, variables, out slug);

            // TODO: Log errors here, we want to know whether the API or the app config is at fault.
            switch (result)
            {
            case DeploymentResult.UnableToCreateApplication:
                return(Response.AsRedirect("/Deploy/" + app.Key).WithErrorFlash(Session, "There was a problem creating the application at AppHarbor."));

            case DeploymentResult.UnableToDeployCode:
                return(Response.AsRedirect("/Deploy/" + app.Key).WithErrorFlash(Session, "There was a problem deploying the application."));

            case DeploymentResult.ErrorInstallingAddons:
                return(Response.AsRedirect("/Sites").WithErrorFlash(Session, "Your site has been deployed but there were problems installing all required addons. The site may not operate as expected."));

            case DeploymentResult.ErrorSettingVariables:
                return(Response.AsRedirect("/Sites").WithErrorFlash(Session, "Your site has been deployed but there were problems setting all the configuration variables. The site may not operate as expected, please log in to AppHarbor to confirm."));

            case DeploymentResult.Success:
                return(Response.AsRedirect("/Sites").WithSuccessFlash(Session, String.Format("{0} deployed into site {1} ({2})", app.Name, appName, slug)));

            default:
                return(Response.AsRedirect("/Deploy/" + app.Key).WithErrorFlash(Session, "There was a problem deploying the application. Double check your deployed application to see whether it was successful or not"));
            }
        }
Exemple #2
0
        public void Deploy_Latest_Succeeds()
        {
            File.Copy(@"../../../testdata/solutiondeploy_tokens.json", "solutiondeploy_tokens.json", true);
            File.Copy(@"../../../testdata/manifest.json", "manifest.json", true);

            sut = BuildService();

            sut.Deploy("authorizationservice", "Azure Prod");

            File.Copy("solutiondeploy_tokens.json", @"../../../testdata/solutiondeploy_tokens.json", true);
        }
Exemple #3
0
        public async Task Run([QueueTrigger("azure-resource-deploy", Connection = "AzureWebJobsStorage")] AzureResourceToDeploy ard,
                              ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {ard.AzureResource.Type.Name}");

            var connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage", EnvironmentVariableTarget.Process);
            //var tableName = Environment.GetEnvironmentVariable("deployLog", EnvironmentVariableTarget.Process);
            var serilog = new LoggerConfiguration()
                          .WriteTo.AzureTableStorage(connectionString, storageTableName: "AldoDeployerLog")
                          .CreateLogger();

            try
            {
                var deployOptions = new DeploymentOptions
                {
                    Region                   = Region.EuropeWest,
                    ResourceGroupName        = "TestCodemotionRome19",
                    UseExistingResourceGroup = true,
                    SubscriptionId           = configuration.SubscriptionId
                };

                var azure = await azureService.Authenticate(configuration.ClientId, configuration.ClientSecret, configuration.TenantId);

                var deployResult = await deploymentService.Deploy(azure, deployOptions, ard.AzureResource);

                const string failed  = "è fallito";
                const string success = "è andato a buon fine";

                var notificationMessage = ard.AzureResource.Name.IsNullOrWhiteSpace() ?
                                          $"Aldo. <p>Il deploy della risorsa <s>{ard.AzureResource.Type.Name}</s> {(deployResult.IsSuccess ? success : failed)}</p>" :
                                          $"Aldo. <p>Il deploy della risorsa <s>{ard.AzureResource.Type.Name}</s> <s>{ard.AzureResource.Name}</s> {(deployResult.IsSuccess ? success : failed)}</p>";

                var notificationResult = await notificationService.SendUserNotification(ard.RequestedByUser, notificationMessage);

                if (notificationResult.IsFailure)
                {
                    serilog.Error(notificationResult.Error);
                }
            }
            catch (Exception e)
            {
                var error = $"{e.Message}\n\r{e.StackTrace}";
                log.LogError(error);
                serilog.Error(error);
            }
        }
        public async Task <ActionResult <Device> > Deploy([FromBody] AddDeviceRequest request)
        {
            var device = await _deployment.Deploy(request);

            return(Ok(device));
        }