Ejemplo n.º 1
0
        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);
        }
 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;
 }
Ejemplo n.º 3
0
 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));
 }
        protected override string ExecuteOperation(CodeActivityContext context)
        {
            var hostedServiceName = context.GetValue<string>(HostedServiceName);
            var slot = context.GetValue(Slot).Description();
            var storageServiceName = context.GetValue<string>(StorageServiceName);
            var deploymentName = context.GetValue<string>(DeploymentName);
            var label = context.GetValue<string>(Label);
            var package = context.GetValue<string>(Package);
            var configuration = context.GetValue<string>(Configuration);

            if (string.IsNullOrEmpty(deploymentName))
            {
                deploymentName = Guid.NewGuid().ToString();
            }

            Uri packageUrl;
            if (package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
                package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase))
            {
                packageUrl = new Uri(package);
            }
            else
            {
                //upload package to blob
                var storageName = string.IsNullOrEmpty(storageServiceName) ? hostedServiceName : storageServiceName;
                packageUrl = this.RetryCall(s =>
                    AzureBlob.UploadPackageToBlob(
                    channel,
                    storageName,
                    s,
                    package));
            }

            //create new deployment package
            var deploymentInput = new CreateDeploymentInput
            {
                PackageUrl = packageUrl,
                Configuration = Utility.GetConfiguration(configuration),
                Label = ServiceManagementHelper.EncodeToBase64String(label),
                Name = deploymentName
            };

            using (new OperationContextScope((IContextChannel)channel))
            {
                try
                {
                    this.RetryCall(s => this.channel.CreateOrUpdateDeployment(
                        s,
                        hostedServiceName,
                        slot,
                        deploymentInput));
                }
                catch (CommunicationException ex)
                {
                    throw new CommunicationExceptionEx(ex);
                }

                return RetrieveOperationId();
            }
        }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
        protected override void PerformOperation(IServiceManagement channel)
        {
            CreateDeploymentInput input = new CreateDeploymentInput
            {
                Name = DeploymentName,
                StartDeployment = true,
                Configuration = Utility.GetSettings(ConfigFileLocation),
            };

            if (!string.IsNullOrEmpty(PackageLocation))
            {
                if (Uri.IsWellFormedUriString(PackageLocation, UriKind.Absolute))
                {
                    input.PackageUrl = new Uri(PackageLocation);
                }
                else
                {
                    //TODO: Propagate timeout parameter
                    input.PackageUrl = UploadFile(PackageLocation, TimeSpan.FromMinutes(60));
                }

            }

            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);
        }
Ejemplo n.º 7
0
		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);
				}
			}
		}