public void PublishService(string serviceRootPath)
        {
            SafeWriteObject(string.Format(Resources.PublishServiceStartMessage, _hostedServiceName));
            SafeWriteObject(string.Empty);

            // Package the service and all of its roles up in the open package format used by Azure
            InitializeSettingsAndCreatePackage(serviceRootPath);

            if (ServiceExists())
            {
                bool deploymentExists = new GetDeploymentStatus(this.Channel).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();
            }
        }
        private void StopAndRemove(string rootName, string serviceName, string subscription, string slot)
        {
            GetDeploymentStatus getDeployment = new GetDeploymentStatus(this.Channel);

            if (getDeployment.DeploymentExists(rootName, serviceName, slot, subscription))
            {
                DeploymentStatusManager setDeployment = new DeploymentStatusManager(this.Channel);
                setDeployment.SetDeploymentStatusProcess(rootName, DeploymentStatus.Suspended, slot, subscription, serviceName);

                getDeployment.WaitForState(DeploymentStatus.Suspended, rootName, serviceName, slot, subscription);

                RemoveAzureDeploymentCommand removeDeployment = new RemoveAzureDeploymentCommand(this.Channel);
                removeDeployment.RemoveAzureDeploymentProcess(rootName, serviceName, slot, subscription);

                while (getDeployment.DeploymentExists(rootName, serviceName, slot, subscription)) ;
            }
        }