public virtual void SetDeploymentStatusProcess(string rootPath, string newStatus, string slot, string subscription, string serviceName)
        {
            string result;

            if (!string.IsNullOrEmpty(subscription))
            {
                var globalComponents = GlobalComponents.Load(GlobalPathInfo.GlobalSettingsDirectory);
                CurrentSubscription = globalComponents.Subscriptions.Values.First(
                    sub => sub.SubscriptionName == subscription);
            }

            // Check that deployment slot for the service exists
            WriteVerboseWithTimestamp(Resources.LookingForDeploymentMessage, slot, serviceName);
            result = CheckDeployment(newStatus, serviceName, slot);

            if (string.IsNullOrEmpty(result))
            {
                SetDeployment(newStatus, serviceName, slot);
                GetDeploymentStatus deploymentStatusCommand = new GetDeploymentStatus(Channel, CommandRuntime)
                { ShareChannel = ShareChannel, CurrentSubscription = CurrentSubscription };
                deploymentStatusCommand.WaitForState(newStatus, rootPath, serviceName, slot, CurrentSubscription.SubscriptionName);
                Deployment deployment = this.RetryCall<Deployment>(s => this.Channel.GetDeploymentBySlot(s, serviceName, slot));

                if (PassThru)
                {
                    WriteObject(deployment);
                }

                WriteVerboseWithTimestamp(string.Format(Resources.ChangeDeploymentStatusCompleteMessage, serviceName, newStatus));
            }
            else
            {
                WriteWarning(result);
            }
        }
        public void PublishService(string serviceRootPath)
        {
            AzureTool.Validate();
            WriteVerbose(string.Format(Resources.PublishServiceStartMessage, _hostedServiceName));

            // Package the service and all of its roles up in the open package format used by Azure
            if (InitializeSettingsAndCreatePackage(serviceRootPath))
            {
                if (ServiceExists())
                {
                    var deploymentStatusCommand = new GetDeploymentStatus(Channel, CommandRuntime)
                    { ShareChannel = ShareChannel, CurrentSubscription = CurrentSubscription };
                    bool deploymentExists = deploymentStatusCommand.DeploymentExists(
                        _azureService.Paths.RootPath,
                        _hostedServiceName,
                        _deploymentSettings.ServiceSettings.Slot,
                        _deploymentSettings.ServiceSettings.Subscription);
                    if (deploymentExists)
                    {
                        UpgradeDeployment();
                    }
                    else
                    {
                        CreateNewDeployment();
                    }
                }
                else
                {
                    CreateHostedService();
                    CreateNewDeployment();
                }

                // Verify the deployment succeeded by checking that each of the
                // roles are running
                VerifyDeployment();

                // After we've finished deploying, optionally launch a browser pointed at the service
                if (Launch && CanGenerateUrlForDeploymentSlot())
                {
                    LaunchService();
                }

                Deployment deployment = this.RetryCall<Deployment>(s => this.Channel.GetDeploymentBySlot(
                    s,
                    _hostedServiceName,
                    _deploymentSettings.ServiceSettings.Slot
                ));
                WriteObject(deployment);
            }
            else
            {
                WriteVerbose(Resources.PublishAbortedAtUserRequest);
            }

            WriteVerboseWithTimestamp(Resources.PublishCompleteMessage);
        }
Ejemplo n.º 3
0
        private void StopAndRemove(string rootName, string serviceName, string subscription, string slot)
        {
            var deploymentStatusCommand = new GetDeploymentStatus(Channel, CommandRuntime)
            { ShareChannel = ShareChannel, CurrentSubscription = CurrentSubscription };
            if (deploymentStatusCommand.DeploymentExists(rootName, serviceName, slot, subscription))
            {
                InvokeInOperationContext(() =>
                {
                    this.RetryCall(s => this.Channel.DeleteDeploymentBySlot(s, serviceName, slot));
                });

                // Wait until deployment is removed
                while (deploymentStatusCommand.DeploymentExists(rootName, serviceName, slot, subscription));
            }
        }