/// <summary> /// Connect to an Azure subscription and execute a VIP swap. /// </summary> /// <returns>The asynchronous operation identifier.</returns> protected override string AzureExecute() { var swapDeploymentInput = new SwapDeploymentInput { SourceDeployment = this.StagingDeploymentName.Get(this.ActivityContext), Production = this.ProductionDeploymentName.Get(this.ActivityContext) }; using (new OperationContextScope((IContextChannel)Channel)) { try { this.RetryCall(s => this.Channel.SwapDeployment(s, this.ServiceName.Get(this.ActivityContext), swapDeploymentInput)); return BaseAzureAsynchronousActivity.RetrieveOperationId(); } catch (EndpointNotFoundException ex) { this.LogBuildMessage(ex.Message); return null; } } }
public IAsyncResult BeginSwapDeployment(string subscriptionId, string serviceName, SwapDeploymentInput input, AsyncCallback callback, object state) { SimpleServiceManagementAsyncResult result = new SimpleServiceManagementAsyncResult(); result.Values["subscriptionId"] = subscriptionId; result.Values["serviceName"] = serviceName; result.Values["input"] = input; result.Values["callback"] = callback; result.Values["state"] = state; return result; }
protected override void PerformOperation(IServiceManagement channel) { SwapDeploymentInput input = new SwapDeploymentInput { Production = DeploymentNameInProduction, SourceDeployment = SourceDeploymentName }; Console.WriteLine("Swapping Deployment"); channel.SwapDeployment(SubscriptionId, HostedServiceName, input); }
public static void SwapDeployment(this IServiceManagement proxy, string subscriptionId, string serviceName, SwapDeploymentInput input) { proxy.EndSwapDeployment(proxy.BeginSwapDeployment(subscriptionId, serviceName, input, null, null)); }
public void MoveDeploymentProcess() { Func<string, Deployment> func = null; Action<string> action = null; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { new List<PersistentVMRoleContext>(); MoveAzureDeploymentCommand moveAzureDeploymentCommand = this; if (func == null) { func = (string s) => base.Channel.GetDeploymentBySlot(s, this.ServiceName, "Production"); } Deployment deployment = ((CmdletBase<IServiceManagement>)moveAzureDeploymentCommand).RetryCall<Deployment>(func); if (deployment.RoleList != null && string.Compare(deployment.RoleList[0].RoleType, "PersistentVMRole", StringComparison.OrdinalIgnoreCase) == 0) { throw new ArgumentException("Cannot Move Deployments with Virtual Machines Present"); } } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (communicationException as EndpointNotFoundException == null || base.IsVerbose()) { this.WriteErrorDetails(communicationException); } } } string deploymentName = this.GetDeploymentName("Production"); string str = this.GetDeploymentName("Staging"); if (str != null) { SwapDeploymentInput swapDeploymentInput = new SwapDeploymentInput(); swapDeploymentInput.SourceDeployment = str; swapDeploymentInput.Production = deploymentName; using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel)) { try { CmdletExtensions.WriteVerboseOutputForObject(this, swapDeploymentInput); MoveAzureDeploymentCommand moveAzureDeploymentCommand1 = this; if (action == null) { action = (string s) => base.Channel.SwapDeployment(s, this.ServiceName, swapDeploymentInput); } ((CmdletBase<IServiceManagement>)moveAzureDeploymentCommand1).RetryCall(action); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } catch (CommunicationException communicationException3) { CommunicationException communicationException2 = communicationException3; this.WriteErrorDetails(communicationException2); } } return; } else { throw new ArgumentException("The Staging deployment slot is empty."); } }