Example #1
0
        public XDocument GetConfiguration(ICertificateStore certificateStore, AzureAccount account, string serviceName, DeploymentSlot slot)
        {
            using (var client = account.CreateComputeManagementClient(certificateStore))
            {
                try
                {
                    var response = client.Deployments.GetBySlot(serviceName, slot);

                    if (response.StatusCode != HttpStatusCode.OK)
                    {
                        throw new Exception(string.Format("Getting deployment by slot returned HTTP Status Code: {0}",
                                                          response.StatusCode));
                    }

                    return(string.IsNullOrEmpty(response.Configuration)
                        ? null
                        : XDocument.Parse(response.Configuration));
                }
                catch (CloudException cloudException)
                {
                    Log.VerboseFormat("Getting deployments for service '{0}', slot {1}, returned:\n{2}", serviceName,
                                      slot.ToString(), cloudException.Message);
                    return(null);
                }
                catch (Hyak.Common.CloudException exception)
                {
                    Log.VerboseFormat("Getting deployments for service '{0}', slot {1}, returned:\n{2}", serviceName,
                                      slot.ToString(), exception.Message);
                    return(null);
                }
            }
        }
Example #2
0
        public int ExecuteHealthCheck()
        {
            var account = new AzureAccount(variables);

            var cloudServiceName = variables.Get(SpecialVariables.Action.Azure.CloudServiceName);

            using (var azureClient = account.CreateComputeManagementClient(certificateStore))
            {
                var azureResponse = azureClient.HostedServices.List();
                if (azureResponse.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception("Azure returned HTTP status-code " + azureResponse.StatusCode);
                }

                var hostedService = azureResponse.HostedServices.FirstOrDefault(hs => hs.ServiceName == cloudServiceName);
                if (hostedService == null)
                {
                    throw new Exception($"Hosted service with name {cloudServiceName} was not found.");
                }
            }

            return(0);
        }