public Add ( Microsoft.WindowsAzure.Management.Compute.Models.DeploymentGetResponse deployment, Microsoft.WindowsAzure.Management.Compute.Models.DeploymentGetResponse peerDeployment, |
||
deployment | Microsoft.WindowsAzure.Management.Compute.Models.DeploymentGetResponse | |
peerDeployment | Microsoft.WindowsAzure.Management.Compute.Models.DeploymentGetResponse | |
inputs | ||
slot | string | |
Résultat | Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration |
public void ExecuteCommand() { InitializeAntimalwareSettings(); ValidateParameters(); RemoveAntimalwareExtension(); RemoveExistingAntimalwareMonitoringConfig(); ExtensionConfigurationInput[] extConfigInputs = null; if (AntimalwareExtensionConfigurationInput != null && AntimalwareMonitoringExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[2]; extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput; extConfigInputs[1] = AntimalwareExtensionConfigurationInput; } else if (AntimalwareExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[1]; extConfigInputs[0] = AntimalwareExtensionConfigurationInput; } else if (AntimalwareMonitoringExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[1]; extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput; } // process any pending deployment changes if (extConfigInputs != null) { ExtensionConfiguration newExtConfig = ExtensionManager.Add(Deployment, extConfigInputs, Slot); ChangeDeployment(newExtConfig); } }
public void ExecuteCommand() { ValidateParameters(); // prepare diagnostics extension switch (monitoringAction) { case MonitoringActionType.Enable: EnableMonitoring(); break; case MonitoringActionType.Disable: RemoveExistingAntimalwareMonitoringConfig(); break; default: break; } // prepare antimalware extension if (isAntimalwareEnabled) { InitializeAntimalwareSettings(); ExtensionConfigurationInput amExtConfigInput = new ExtensionConfigurationInput { ProviderNameSpace = ProviderNamespace, Type = ExtensionName, PublicConfiguration = PublicConfiguration, PrivateConfiguration = PrivateConfiguration, Roles = new ExtensionRoleList(Role != null && Role.Any() ? Role.Select(r => new ExtensionRole(r)) : Enumerable.Repeat(new ExtensionRole(), 1)) }; AntimalwareExtensionConfigurationInput = amExtConfigInput; } // update extensions as appropriate ExtensionConfigurationInput[] extConfigInputs = null; if (AntimalwareExtensionConfigurationInput != null && AntimalwareMonitoringExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[2]; extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput; extConfigInputs[1] = AntimalwareExtensionConfigurationInput; } else if (AntimalwareExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[1]; extConfigInputs[0] = AntimalwareExtensionConfigurationInput; } else if (AntimalwareMonitoringExtensionConfigurationInput != null) { extConfigInputs = new ExtensionConfigurationInput[1]; extConfigInputs[0] = AntimalwareMonitoringExtensionConfigurationInput; } // process any pending deployment changes if (extConfigInputs != null) { ExtensionConfiguration newExtConfig = ExtensionManager.Add(Deployment, PeerDeployment, extConfigInputs, Slot); ChangeDeployment(newExtConfig); } }
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)); } }