コード例 #1
0
        public HttpResponseMessage GetResult(string id)
        {
            using (_tracer.Step("DeploymentService.GetResult"))
            {
                DeployResult pending;
                if (IsLatestPendingDeployment(ref id, out pending))
                {
                    var response = Request.CreateResponse(HttpStatusCode.Accepted, ArmUtils.AddEnvelopeOnArmRequest(pending, Request));
                    response.Headers.Location = Request.RequestUri;
                    return(response);
                }

                DeployResult result = _deploymentManager.GetResult(id);

                if (result == null)
                {
                    var response = Request.CreateErrorResponse(HttpStatusCode.NotFound, String.Format(CultureInfo.CurrentCulture,
                                                                                                      Resources.Error_DeploymentNotFound,
                                                                                                      id));
                    throw new HttpResponseException(response);
                }

                result.Url    = Request.RequestUri;
                result.LogUrl = UriHelper.MakeRelative(Request.RequestUri, "log");

                return(Request.CreateResponse(HttpStatusCode.OK, ArmUtils.AddEnvelopeOnArmRequest(result, Request)));
            }
        }
コード例 #2
0
        public void HandleAutoSwap(bool verifyActiveDeploymentIdChanged)
        {
            if (!IsAutoSwapEnabled())
            {
                return;
            }

            var tracer = _traceFactory.GetTracer();

            string currentActiveDeploymentId = _deploymentStatusManager.ActiveDeploymentId;

            if (verifyActiveDeploymentIdChanged && currentActiveDeploymentId == _initialActiveDeplymentId)
            {
                tracer.Trace("Deployment haven't changed, no need for auto swap", currentActiveDeploymentId);
                return;
            }

            DeployResult latestDeploymentResult = _deploymentManager.GetResult(currentActiveDeploymentId);

            if (latestDeploymentResult.Status != DeployStatus.Success)
            {
                tracer.Trace("Auto swap is not requested as the deployment did not succeed", latestDeploymentResult.Id, latestDeploymentResult.Status);
                return;
            }

            try
            {
                FileSystemHelpers.WriteAllTextToFile(_autoSwapLockFilePath, String.Empty);
            }
            catch (Exception ex)
            {
                tracer.TraceError(ex);
            }

            string operationId  = "AUTOSWAP" + Guid.NewGuid();
            string deploymentId = latestDeploymentResult.Id;

            HttpResponse response = HttpContext.Current.Response;

            response.Headers.Add("X-MS-SWAP-OPERATIONID", operationId);
            response.Headers.Add("X-MS-SWAP-SLOTNAME", _autoSwapSlotName);
            response.Headers.Add("X-MS-SWAP-DEPLOYMENTID", deploymentId);

            tracer.Trace("Requesting auto swap to slot name - '{0}', operation id - '{1}', deployment id - '{2}'".FormatInvariant(_autoSwapSlotName, operationId, deploymentId));
        }
コード例 #3
0
        public DeployResult GetResult(string id)
        {
            using (_tracer.Step("DeploymentService.GetResult"))
            {
                DeployResult result = _deploymentManager.GetResult(id);

                if (result == null)
                {
                    var response = Request.CreateErrorResponse(HttpStatusCode.NotFound, String.Format(CultureInfo.CurrentCulture,
                                                                                                      Resources.Error_DeploymentNotFound,
                                                                                                      id));
                    throw new HttpResponseException(response);
                }

                result.Url    = Request.RequestUri;
                result.LogUrl = UriHelper.MakeRelative(Request.RequestUri, "log");

                return(result);
            }
        }
コード例 #4
0
 public ActionResult GetResult(string id)
 {
     return(Json(_deploymentManager.GetResult(id), JsonRequestBehavior.AllowGet));
 }