private void VerifyDeploymentExists(HostedServiceGetDetailedResponse cloudService, DeploymentSlot slot, out string name) { bool exists = false; if (cloudService.Deployments != null) { exists = cloudService.Deployments.Any(d => d.DeploymentSlot == slot ); } if (exists) { name = cloudService.Deployments.First(d => d.DeploymentSlot == slot).Name; } else { throw new Exception(string.Format(Resources.CannotFindDeployment, cloudService.ServiceName, slot)); } }
private Task<HostedServiceGetDetailedResponse> CreateGetDetailedResponse(string serviceName) { var service = Services.FirstOrDefault(s => s.Name == serviceName); Task<HostedServiceGetDetailedResponse> resultTask; if (service != null) { var response = new HostedServiceGetDetailedResponse { ServiceName = service.Name, StatusCode = HttpStatusCode.OK, }; if (service.ProductionDeployment != null) { response.Deployments.Add(CreateDeploymentResponse(service.ProductionDeployment)); } if (service.StagingDeployment != null) { response.Deployments.Add(CreateDeploymentResponse(service.StagingDeployment)); } resultTask = Tasks.FromResult(response); } else { resultTask = Tasks.FromException<HostedServiceGetDetailedResponse>(ClientMocks.Make404Exception()); } return resultTask; }
/// <summary> /// Writes selected fields of the give HostedServiceGetDetailedResponse /// object out to the console. /// </summary> /// <param name="service"> /// The HostedServiceGetDetailedResponse object to display. /// </param> private static void DisplayServiceInformation(HostedServiceGetDetailedResponse service) { Console.WriteLine("Service Name {0}:", service.ServiceName); Console.WriteLine(" Date Created = {0}", service.Properties.DateCreated); Console.WriteLine(" Date Last Modified = {0}", service.Properties.DateLastModified); Console.WriteLine(" Description = {0}", service.Properties.Description); Console.WriteLine(" Label = {0}", service.Properties.Label); Console.WriteLine(" Location = {0}", service.Properties.Location); Console.WriteLine(" Status = {0}", service.Properties.Status); #if false foreach(string size in service.ComputeCapabilities.VirtualMachinesRoleSizes) { Console.WriteLine("VM Role Size = {0}", size); } Console.WriteLine("URI = {0}", service.Uri); #endif if (service.Deployments.Count == 0) { Console.WriteLine(" No current deployments!"); } foreach (HostedServiceGetDetailedResponse.Deployment deployment in service.Deployments) { Console.WriteLine(); Console.WriteLine(" Deployment Name {0}:", deployment.Name); Console.WriteLine(" Created = {0}", deployment.CreatedTime); Console.WriteLine(" Label = {0}", deployment.Label); Console.WriteLine(" Slot = {0}", deployment.DeploymentSlot); Console.WriteLine(" Status = {0}", deployment.Status); Console.WriteLine(" Instances = {0}", deployment.RoleInstances.Count); ////Console.WriteLine(deployment.Configuration); } }