/// <summary> /// Create a new deployment for the service. /// </summary> private void CreateNewDeployment() { Debug.Assert( !string.IsNullOrEmpty(_hostedServiceName), "_hostedServiceName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.Slot), "Slot cannot be null or empty."); CreateDeploymentInput deploymentInput = new CreateDeploymentInput { PackageUrl = UploadPackage(), Configuration = GetConfiguration(), Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Name = _deploymentSettings.DeploymentName, StartDeployment = true, }; InvokeInOperationContext(() => { RetryCall(subscription => Channel.CreateOrUpdateDeployment( subscription, _hostedServiceName, _deploymentSettings.ServiceSettings.Slot, deploymentInput)); WaitForDeploymentToStart(); }); }
protected override void PerformOperation(IServiceManagement channel) { CreateDeploymentInput input = new CreateDeploymentInput { Name = DeploymentName, Configuration = Utility.GetSettings(ConfigFileLocation), }; if (!string.IsNullOrEmpty(PackageLocation)) { input.PackageUrl = new Uri(PackageLocation); } if (!string.IsNullOrEmpty(Label)) { input.Label = ServiceManagementHelper.EncodeToBase64String(Label); } if (TreatWarningsAsError) { input.TreatWarningsAsError = TreatWarningsAsError; } Console.WriteLine("Creating Deployment... Name: {0}, Label: {1}", DeploymentName, Label); channel.CreateOrUpdateDeployment(SubscriptionId, HostedServiceName, DeploymentSlot, input); }
private void CreateDeployment(PublishContext context) { CreateDeploymentInput deploymentInput = new CreateDeploymentInput { PackageUrl = UploadPackage(context), Configuration = General.GetConfiguration(context.ConfigPath), Label = context.ServiceName, Name = context.DeploymentName, StartDeployment = true, }; WriteVerboseWithTimestamp(Resources.PublishStartingMessage); CertificateList uploadedCertificates = ServiceManagementChannel.ListCertificates( subscriptionId, context.ServiceName); AddCertificates(uploadedCertificates, context); ServiceManagementChannel.CreateOrUpdateDeployment( subscriptionId, context.ServiceName, context.ServiceSettings.Slot, deploymentInput); }
public void NewPaaSDeploymentProcess() { bool removePackage = false; AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Production); AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Staging); var storageName = CurrentSubscription.CurrentStorageAccount; Uri packageUrl; if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(this.Package); } else { var progress = new ProgressRecord(0, "Please wait...", "Uploading package to blob storage"); WriteProgress(progress); removePackage = true; packageUrl = this.RetryCall(s => AzureBlob.UploadPackageToBlob( this.Channel, storageName, s, this.Package, null)); } var deploymentInput = new CreateDeploymentInput { PackageUrl = packageUrl, Configuration = General.GetConfiguration(this.Configuration), Label = this.Label, Name = this.Name, StartDeployment = !this.DoNotStart.IsPresent, TreatWarningsAsError = this.TreatWarningsAsError.IsPresent }; using (new OperationContextScope(Channel.ToContextChannel())) { try { var progress = new ProgressRecord(0, "Please wait...", "Creating the new deployment"); WriteProgress(progress); ExecuteClientAction(deploymentInput, CommandRuntime.ToString(), s => this.Channel.CreateOrUpdateDeployment(s, this.ServiceName, this.Slot, deploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.Channel, storageName, s, packageUrl)); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } } }
public static void CreateOrUpdateDeployment(this IServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, CreateDeploymentInput input) { proxy.EndCreateOrUpdateDeployment(proxy.BeginCreateOrUpdateDeployment(subscriptionId, serviceName, deploymentSlot, input, null, null)); }
/// <summary> /// Create a new deployment for the service. /// </summary> private void CreateNewDeployment() { Debug.Assert( !string.IsNullOrEmpty(_hostedServiceName), "_hostedServiceName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.Slot), "Slot cannot be null or empty."); CreateDeploymentInput deploymentInput = new CreateDeploymentInput { PackageUrl = UploadPackage(), Configuration = GetConfiguration(), Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Name = _deploymentSettings.DeploymentName, StartDeployment = true, }; CertificateList uploadedCertificates = RetryCall<CertificateList>(subscription => Channel.ListCertificates(subscription, _hostedServiceName)); AddCertificates(uploadedCertificates); InvokeInOperationContext(() => { RetryCall(subscription => Channel.CreateOrUpdateDeployment( subscription, _hostedServiceName, _deploymentSettings.ServiceSettings.Slot, deploymentInput)); WaitForDeploymentToStart(); }); }
public void NewPaaSDeploymentProcess() { bool removePackage = false; AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Production); AssertNoPersistenVmRoleExistsInDeployment(DeploymentSlotType.Staging); var storageName = CurrentSubscription.CurrentStorageAccount; Uri packageUrl; if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(this.Package); } else { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.UploadingPackage); WriteProgress(progress); removePackage = true; packageUrl = this.RetryCall(s => AzureBlob.UploadPackageToBlob( this.Channel, storageName, s, this.Package, null)); } ExtensionConfiguration extConfig = null; if (ExtensionConfiguration != null) { var roleList = (from c in ExtensionConfiguration where c != null from r in c.Roles select r).GroupBy(r => r.ToString()).Select(g => g.First()); foreach (var role in roleList) { var result = from c in ExtensionConfiguration where c != null && c.Roles.Any(r => r.ToString() == role.ToString()) select string.Format("{0}.{1}", c.ProviderNameSpace, c.Type); foreach (var s in result) { if (result.Count(t => t == s) > 1) { throw new Exception(string.Format(Resources.ServiceExtensionCannotApplyExtensionsInSameType, s)); } } } ExtensionManager extensionMgr = new ExtensionManager(this, ServiceName); Deployment currentDeployment = null; ExtensionConfiguration deploymentExtensionConfig = null; using (new OperationContextScope(Channel.ToContextChannel())) { try { currentDeployment = this.RetryCall(s => this.Channel.GetDeploymentBySlot(s, this.ServiceName, Slot)); deploymentExtensionConfig = currentDeployment == null ? null : extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ToConfiguration(); } catch (ServiceManagementClientException ex) { if (ex.HttpStatus != HttpStatusCode.NotFound && IsVerbose() == false) { this.WriteErrorDetails(ex); } } } ExtensionConfigurationBuilder configBuilder = extensionMgr.GetBuilder(); foreach (ExtensionConfigurationInput context in ExtensionConfiguration) { if (context != null) { if (context.X509Certificate != null) { var operationDescription = string.Format(Resources.ServiceExtensionUploadingCertificate, CommandRuntime, context.X509Certificate.Thumbprint); ExecuteClientActionInOCS(null, operationDescription, s => this.Channel.AddCertificates(s, this.ServiceName, CertUtils.Create(context.X509Certificate))); } ExtensionConfiguration currentConfig = extensionMgr.InstallExtension(context, Slot, deploymentExtensionConfig); foreach (var r in currentConfig.AllRoles) { if (currentDeployment == null || !extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(r.Id)) { configBuilder.AddDefault(r.Id); } } foreach (var r in currentConfig.NamedRoles) { foreach (var e in r.Extensions) { if (currentDeployment == null || !extensionMgr.GetBuilder(currentDeployment.ExtensionConfiguration).ExistAny(e.Id)) { configBuilder.Add(r.RoleName, e.Id); } } } } } extConfig = configBuilder.ToConfiguration(); } var deploymentInput = new CreateDeploymentInput { PackageUrl = packageUrl, Configuration = General.GetConfiguration(this.Configuration), ExtensionConfiguration = extConfig, Label = this.Label, Name = this.Name, StartDeployment = !this.DoNotStart.IsPresent, TreatWarningsAsError = this.TreatWarningsAsError.IsPresent }; using (new OperationContextScope(Channel.ToContextChannel())) { try { var progress = new ProgressRecord(0, Resources.WaitForUploadingPackage, Resources.CreatingNewDeployment); WriteProgress(progress); ExecuteClientAction(deploymentInput, CommandRuntime.ToString(), s => this.Channel.CreateOrUpdateDeployment(s, this.ServiceName, this.Slot, deploymentInput)); if (removePackage == true) { this.RetryCall(s => AzureBlob.DeletePackageFromBlob( this.Channel, storageName, s, packageUrl)); } } catch (ServiceManagementClientException ex) { this.WriteErrorDetails(ex); } } }
public void NewPaaSDeploymentProcess() { NewAzureDeploymentCommand.NewAzureDeploymentCommand variable = null; Func <string, Deployment> func = null; Func <string, Uri> func1 = null; Action <string> action = null; Action <string> action1 = null; bool flag = false; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { new List <PersistentVMRoleContext>(); NewAzureDeploymentCommand newAzureDeploymentCommand = this; if (func == null) { func = (string s) => base.Channel.GetDeploymentBySlot(s, this.ServiceName, "Production"); } Deployment deployment = ((CmdletBase <IServiceManagement>)newAzureDeploymentCommand).RetryCall <Deployment>(func); if (deployment.RoleList != null && string.Compare(deployment.RoleList[0].RoleType, "PersistentVMRole", StringComparison.OrdinalIgnoreCase) == 0) { throw new ArgumentException("Cannot Create New Deployment with Virtual Machines Present"); } } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (communicationException as EndpointNotFoundException == null && !base.IsVerbose()) { this.WriteErrorDetails(communicationException); } } } string currentStorageAccount = base.get_CurrentSubscription().get_CurrentStorageAccount(); if (this.Package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || this.Package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { Uri uri = new Uri(this.Package); } else { ProgressRecord progressRecord = new ProgressRecord(0, "Please wait...", "Uploading package to blob storage"); base.WriteProgress(progressRecord); flag = true; NewAzureDeploymentCommand.NewAzureDeploymentCommand variable1 = variable; NewAzureDeploymentCommand newAzureDeploymentCommand1 = this; if (func1 == null) { func1 = (string s) => AzureBlob.UploadPackageToBlob(base.Channel, currentStorageAccount, s, this.Package); } variable1.packageUrl = ((CmdletBase <IServiceManagement>)newAzureDeploymentCommand1).RetryCall <Uri>(func1); } CreateDeploymentInput createDeploymentInput = new CreateDeploymentInput(); createDeploymentInput.PackageUrl = uri; createDeploymentInput.Configuration = Utility.GetConfiguration(this.Configuration); createDeploymentInput.Label = ServiceManagementHelper.EncodeToBase64String(this.Label); createDeploymentInput.Name = this.Name; SwitchParameter doNotStart = this.DoNotStart; createDeploymentInput.StartDeployment = new bool?(!doNotStart.IsPresent); SwitchParameter treatWarningsAsError = this.TreatWarningsAsError; createDeploymentInput.TreatWarningsAsError = new bool?(treatWarningsAsError.IsPresent); CreateDeploymentInput createDeploymentInput1 = createDeploymentInput; using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel)) { try { ProgressRecord progressRecord1 = new ProgressRecord(0, "Please wait...", "Creating the new deployment"); base.WriteProgress(progressRecord1); CmdletExtensions.WriteVerboseOutputForObject(this, createDeploymentInput1); NewAzureDeploymentCommand newAzureDeploymentCommand2 = this; if (action == null) { action = (string s) => this.Channel.CreateOrUpdateDeployment(s, this.ServiceName, this.Slot, this.deploymentInput); } ((CmdletBase <IServiceManagement>)newAzureDeploymentCommand2).RetryCall(action); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.OperationDescription = base.CommandRuntime.ToString(); managementOperationContext.OperationId = operation.OperationTrackingId; managementOperationContext.OperationStatus = operation.Status; ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); if (flag) { NewAzureDeploymentCommand newAzureDeploymentCommand3 = this; if (action1 == null) { action1 = (string s) => AzureBlob.DeletePackageFromBlob(base.Channel, currentStorageAccount, s, uri); } ((CmdletBase <IServiceManagement>)newAzureDeploymentCommand3).RetryCall(action1); } } catch (CommunicationException communicationException3) { CommunicationException communicationException2 = communicationException3; this.WriteErrorDetails(communicationException2); } } }
public IAsyncResult BeginCreateOrUpdateDeployment(string subscriptionId, string serviceName, string deploymentSlot, CreateDeploymentInput input, AsyncCallback callback, object state) { SimpleServiceManagementAsyncResult result = new SimpleServiceManagementAsyncResult(); result.Values["subscriptionId"] = subscriptionId; result.Values["serviceName"] = serviceName; result.Values["deploymentSlot"] = deploymentSlot; result.Values["input"] = input; result.Values["callback"] = callback; result.Values["state"] = state; return result; }