public void ExecuteCommand() { string configString = string.Empty; if (!string.IsNullOrEmpty(Configuration)) { configString = GeneralUtilities.GetConfiguration(Configuration); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { string errorConfigInput = null; if (!ExtensionManager.Validate(ExtensionConfiguration, out errorConfigInput)) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, errorConfigInput)); } foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null && context.X509Certificate != null) { ExecuteClientActionNewSM( null, string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint), () => this.ComputeClient.ServiceCertificates.Create(this.ServiceName, CertUtilsNewSM.Create(context.X509Certificate))); } } var slotType = (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true); DeploymentGetResponse d = null; InvokeInOperationContext(() => { try { d = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slotType); } catch (CloudException ex) { if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteExceptionDetails(ex); } } }); ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); extConfig = extensionMgr.Add(d, ExtensionConfiguration, this.Slot); } // Upgrade Parameter Set if (string.Compare(ParameterSetName, "Upgrade", StringComparison.OrdinalIgnoreCase) == 0) { bool removePackage = false; var storageName = CurrentContext.Subscription.GetProperty(AzureSubscription.Property.StorageAccount); Uri packageUrl = null; if (Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(Package); } else { if (string.IsNullOrEmpty(storageName)) { throw new ArgumentException(Resources.CurrentStorageAccountIsNotSet); } var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; InvokeInOperationContext(() => packageUrl = RetryCall(s => AzureBlob.UploadPackageToBlob(this.StorageClient, storageName, Package, null))); } DeploymentUpgradeMode upgradeMode; if (!Enum.TryParse<DeploymentUpgradeMode>(Mode, out upgradeMode)) { upgradeMode = DeploymentUpgradeMode.Auto; } var upgradeDeploymentInput = new DeploymentUpgradeParameters { Mode = upgradeMode, Configuration = configString, ExtensionConfiguration = extConfig, PackageUri = packageUrl, Label = Label ?? ServiceName, Force = Force.IsPresent }; if (!string.IsNullOrEmpty(RoleName)) { upgradeDeploymentInput.RoleToUpgrade = RoleName; } InvokeInOperationContext(() => { try { ExecuteClientActionNewSM( upgradeDeploymentInput, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpgradeBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), upgradeDeploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.StorageClient, storageName, packageUrl)); } } catch (CloudException ex) { this.WriteExceptionDetails(ex); } }); } else if (string.Compare(this.ParameterSetName, "Config", StringComparison.OrdinalIgnoreCase) == 0) { // Config parameter set var changeDeploymentStatusParams = new DeploymentChangeConfigurationParameters { Configuration = configString, ExtensionConfiguration = extConfig }; ExecuteClientActionNewSM( changeDeploymentStatusParams, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.ChangeConfigurationBySlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), changeDeploymentStatusParams)); } else { // Status parameter set var updateDeploymentStatusParams = new DeploymentUpdateStatusParameters { Status = (UpdatedDeploymentStatus)Enum.Parse(typeof(UpdatedDeploymentStatus), this.NewStatus, true) }; ExecuteClientActionNewSM( null, CommandRuntime.ToString(), () => this.ComputeClient.Deployments.UpdateStatusByDeploymentSlot( this.ServiceName, (DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true), updateDeploymentStatusParams)); } }
/// <summary> /// The Upgrade Deployment By Slot operation initiates an update of /// role instances in a deployment using the package and configuration /// that you specify. For more information about updating role /// instances, see Update an Azure Service at /// http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. /// This operation is an asynchronous operation. To determine whether /// the request has been processed, call Get Operation Status. For /// more information on asynchronous operations, see Tracking /// Asynchronous Service Management Requests at /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. /// To perform an automatic update of a deployment, call Upgrade /// Deployment or Change Deployment Configuration with the Mode /// element set to automatic. The update proceeds from that point /// without a need for further input. You can call Get Operation /// Status to determine when the update is complete. To perform a /// manual update, first call Upgrade Deployment with the Mode element /// set to manual. Next, call Walk Upgrade Domain to update each /// domain within the deployment. You should make sure that the /// operation is complete by calling Get Operation Status before /// updating the next domain. Important: An update that adds or /// removes role instances will result in a configuration update to /// all roles that are deployed in the cloud service. Existing role /// instances need to be notified of new role instances so that all /// role instances can communicate together in the cloud service. By /// default, a cloud service is deployed with five update domains, /// which are updated one at a time during an in-place update. For /// information on modifying the number of update domains in the /// service definition file, see the Azure Service Definition Schema /// (.csdef File). To determine the update domain in which a /// particular instance is running in Windows Azure, use the /// UpdateDomain property of the RoleInstance class. See the Azure /// Managed Library Reference at /// http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx /// for more information. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// Required. The cloud service to upgrade. /// </param> /// <param name='deploymentSlot'> /// Required. The slot to upgrade. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Upgrade Deployment By Slot /// operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request and error information regarding /// the failure. /// </returns> public static Task<OperationStatusResponse> UpgradeBySlotAsync(this IDeploymentOperations operations, string serviceName, DeploymentSlot deploymentSlot, DeploymentUpgradeParameters parameters) { return operations.UpgradeBySlotAsync(serviceName, deploymentSlot, parameters, CancellationToken.None); }
protected PSArgument[] CreateDeploymentUpgradeByNameParameters() { string serviceName = string.Empty; string deploymentName = string.Empty; DeploymentUpgradeParameters parameters = new DeploymentUpgradeParameters(); return ConvertFromObjectsToArguments(new string[] { "ServiceName", "DeploymentName", "Parameters" }, new object[] { serviceName, deploymentName, parameters }); }
/// <summary> /// The Begin Upgrading Deployment By Slot operation initiates an /// update of role instances in a deployment using the package and /// configuration that you specify. For more information about /// updating role instances, see Update an Azure Service at /// http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx.This /// operation is an asynchronous operation. To determine whether the /// request has been processed, call Get Operation Status. For more /// information on asynchronous operations, see Tracking Asynchronous /// Service Management Requests at /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. /// To perform an automatic update of a deployment, call Upgrade /// Deployment or Change Deployment Configuration with the Mode /// element set to automatic. The update proceeds from that point /// without a need for further input. You can call Get Operation /// Status to determine when the update is complete. To perform a /// manual update, first call Upgrade Deployment with the Mode element /// set to manual. Next, call Walk Upgrade Domain to update each /// domain within the deployment. You should make sure that the /// operation is complete by calling Get Operation Status before /// updating the next domain. Important: An update that adds or /// removes role instances will result in a configuration update to /// all roles that are deployed in the cloud service. Existing role /// instances need to be notified of new role instances so that all /// role instances can communicate together in the cloud service. By /// default, a cloud service is deployed with five update domains, /// which are updated one at a time during an in-place update. For /// information on modifying the number of update domains in the /// service definition file, see the Azure Service Definition Schema /// (.csdef File). To determine the update domain in which a /// particular instance is running in Windows Azure, use the /// UpdateDomain property of the RoleInstance class. See the Azure /// Managed Library Reference at /// http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx /// for more information. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// Required. The cloud service to upgrade. /// </param> /// <param name='deploymentSlot'> /// Required. The slot to upgrade. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Upgrading Deployment By /// Slot operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<AzureOperationResponse> BeginUpgradingBySlotAsync(this IDeploymentOperations operations, string serviceName, DeploymentSlot deploymentSlot, DeploymentUpgradeParameters parameters) { return operations.BeginUpgradingBySlotAsync(serviceName, deploymentSlot, parameters, CancellationToken.None); }
/// <summary> /// The Upgrade Deployment By Slot operation initiates an update of /// role instances in a deployment using the package and configuration /// that you specify. For more information about updating role /// instances, see Update an Azure Service at /// http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. /// This operation is an asynchronous operation. To determine whether /// the request has been processed, call Get Operation Status. For /// more information on asynchronous operations, see Tracking /// Asynchronous Service Management Requests at /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. /// To perform an automatic update of a deployment, call Upgrade /// Deployment or Change Deployment Configuration with the Mode /// element set to automatic. The update proceeds from that point /// without a need for further input. You can call Get Operation /// Status to determine when the update is complete. To perform a /// manual update, first call Upgrade Deployment with the Mode element /// set to manual. Next, call Walk Upgrade Domain to update each /// domain within the deployment. You should make sure that the /// operation is complete by calling Get Operation Status before /// updating the next domain. Important: An update that adds or /// removes role instances will result in a configuration update to /// all roles that are deployed in the cloud service. Existing role /// instances need to be notified of new role instances so that all /// role instances can communicate together in the cloud service. By /// default, a cloud service is deployed with five update domains, /// which are updated one at a time during an in-place update. For /// information on modifying the number of update domains in the /// service definition file, see the Azure Service Definition Schema /// (.csdef File). To determine the update domain in which a /// particular instance is running in Windows Azure, use the /// UpdateDomain property of the RoleInstance class. See the Azure /// Managed Library Reference at /// http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx /// for more information. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// Required. The cloud service to upgrade. /// </param> /// <param name='deploymentSlot'> /// Required. The slot to upgrade. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Upgrade Deployment By Slot /// operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request and error information regarding /// the failure. /// </returns> public static OperationStatusResponse UpgradeBySlot(this IDeploymentOperations operations, string serviceName, DeploymentSlot deploymentSlot, DeploymentUpgradeParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IDeploymentOperations)s).UpgradeBySlotAsync(serviceName, deploymentSlot, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Begin Upgrading Deployment By Name operation initiates an /// update of role instances in a deployment using the package and /// configuration that you specify. For more information about /// updating role instances, see Update an Azure Service at /// http://msdn.microsoft.com/en-us/library/windowsazure/hh472157.aspx. /// This operation is an asynchronous operation. To determine whether /// the request has been processed, call Get Operation Status. For /// more information on asynchronous operations, see Tracking /// Asynchronous Service Management Requests at /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460791.aspx. /// To perform an automatic update of a deployment, call Upgrade /// Deployment or Change Deployment Configuration with the Mode /// element set to automatic. The update proceeds from that point /// without a need for further input. You can call Get Operation /// Status to determine when the update is complete. To perform a /// manual update, first call Upgrade Deployment with the Mode element /// set to manual. Next, call Walk Upgrade Domain to update each /// domain within the deployment. You should make sure that the /// operation is complete by calling Get Operation Status before /// updating the next domain. Important: An update that adds or /// removes role instances will result in a configuration update to /// all roles that are deployed in the cloud service. Existing role /// instances need to be notified of new role instances so that all /// role instances can communicate together in the cloud service. By /// default, a cloud service is deployed with five update domains, /// which are updated one at a time during an in-place update. For /// information on modifying the number of update domains in the /// service definition file, see the Azure Service Definition Schema /// (.csdef File). To determine the update domain in which a /// particular instance is running in Windows Azure, use the /// UpdateDomain property of the RoleInstance class. See the Azure /// Managed Library Reference at /// http://msdn.microsoft.com/en-us/library/windowsazure/dd179380.aspx /// for more information. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// Required. The cloud service to upgrade. /// </param> /// <param name='deploymentName'> /// Required. The deployment to upgrade. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Begin Upgrading Deployment By /// Name operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static AzureOperationResponse BeginUpgradingByName(this IDeploymentOperations operations, string serviceName, string deploymentName, DeploymentUpgradeParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IDeploymentOperations)s).BeginUpgradingByNameAsync(serviceName, deploymentName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
private void UpgradeDeployment(PublishContext context, bool forceUpgrade) { Uri packageUri = UploadPackageIfNeeded(context); var upgradeParams = new DeploymentUpgradeParameters { Configuration = GeneralUtilities.GetConfiguration(context.CloudConfigPath), PackageUri = packageUri, Label = context.ServiceName, Mode = DeploymentUpgradeMode.Auto, Force = forceUpgrade }; WriteVerboseWithTimestamp(Resources.PublishUpgradingMessage); var uploadedCertificates = ComputeClient.ServiceCertificates.List(context.ServiceName); AddCertificates(uploadedCertificates, context); ComputeClient.Deployments.UpgradeBySlot(context.ServiceName, GetSlot(context.ServiceSettings.Slot), upgradeParams); }
/// <summary> /// The Upgrade Deployment operation initiates an update of role /// instances in a deployment using the package and configuration that /// you specify. For more information about updating role instances, /// see Update a Windows Azure Service. The Upgrade Deployment /// operation is an asynchronous operation. To determine whether the /// request has been processed, call Get Operation Status. For more /// information on asynchronous operations, see Tracking Asynchronous /// Service Management Requests.To perform an automatic update of a /// deployment, call Upgrade Deployment or Change Deployment /// Configuration with the Mode element set to automatic. The update /// proceeds from that point without a need for further input. You can /// call Get Operation Status to determine when the update is /// complete. To perform a manual update, first call Upgrade /// Deployment with the Mode element set to manual. Next, call Walk /// Upgrade Domain to update each domain within the deployment. You /// should make sure that the operation is complete by calling Get /// Operation Status before updating the next domain. Important: An /// update that adds or removes role instances will result in a /// configuration update to all roles that are deployed in the cloud /// service. Existing role instances need to be notified of new role /// instances so that all role instances can communicate together in /// the cloud service. By default, a cloud service is deployed with /// five update domains, which are updated one at a time during an /// in-place update. For information on modifying the number of update /// domains in the service definition file, see Windows Azure Service /// Definition Schema (.csdef File). To determine the update domain /// in which a particular instance is running in Windows Azure, use /// the UpdateDomain property of the RoleInstance class. See the /// Windows Azure Managed Library Reference for more information. /// (see http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// The cloud service to upgrade. /// </param> /// <param name='deploymentSlot'> /// The slot to upgrade. /// </param> /// <param name='parameters'> /// Parameters supplied to the Upgrade Deployment operation. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static ComputeOperationStatusResponse UpgradeBySlot(this IDeploymentOperations operations, string serviceName, DeploymentSlot deploymentSlot, DeploymentUpgradeParameters parameters) { try { return operations.UpgradeBySlotAsync(serviceName, deploymentSlot, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Upgrade Deployment operation initiates an update of role /// instances in a deployment using the package and configuration that /// you specify. For more information about updating role instances, /// see Update a Windows Azure Service. The Upgrade Deployment /// operation is an asynchronous operation. To determine whether the /// request has been processed, call Get Operation Status. For more /// information on asynchronous operations, see Tracking Asynchronous /// Service Management Requests.To perform an automatic update of a /// deployment, call Upgrade Deployment or Change Deployment /// Configuration with the Mode element set to automatic. The update /// proceeds from that point without a need for further input. You can /// call Get Operation Status to determine when the update is /// complete. To perform a manual update, first call Upgrade /// Deployment with the Mode element set to manual. Next, call Walk /// Upgrade Domain to update each domain within the deployment. You /// should make sure that the operation is complete by calling Get /// Operation Status before updating the next domain. Important: An /// update that adds or removes role instances will result in a /// configuration update to all roles that are deployed in the cloud /// service. Existing role instances need to be notified of new role /// instances so that all role instances can communicate together in /// the cloud service. By default, a cloud service is deployed with /// five update domains, which are updated one at a time during an /// in-place update. For information on modifying the number of update /// domains in the service definition file, see Windows Azure Service /// Definition Schema (.csdef File). To determine the update domain /// in which a particular instance is running in Windows Azure, use /// the UpdateDomain property of the RoleInstance class. See the /// Windows Azure Managed Library Reference for more information. /// (see http://msdn.microsoft.com/en-us/library/windowsazure/ee460793.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Compute.IDeploymentOperations. /// </param> /// <param name='serviceName'> /// The cloud service to upgrade. /// </param> /// <param name='deploymentName'> /// The deployment to upgrade. /// </param> /// <param name='parameters'> /// Parameters supplied to the Upgrade Deployment operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse BeginUpgradingByName(this IDeploymentOperations operations, string serviceName, string deploymentName, DeploymentUpgradeParameters parameters) { try { return operations.BeginUpgradingByNameAsync(serviceName, deploymentName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
public virtual async Task<OperationResponse> UpgradeDeployment(DeploymentUpgradeParameters upgradeParameters, DeploymentSlot slot = DeploymentSlot.Production) { return await _computeClient.Value.Deployments.BeginUpgradingBySlotAsync(this.ServiceName, slot, upgradeParameters); }