Esempio n. 1
0
        static OperationStatus GetOperationStatus(OperationStatus operationStatus)
        {
            OperationStatus opsStatus = null;

            try
            {
                // Uri operationUri = new Uri("http://localhost:4652/api/operationstatus");
                Uri operationUri = new Uri("http://localhost:8080/api/deployment");
                // Uri operationUri = new Uri("http://ec2-23-23-186-66.compute-1.amazonaws.com/BermudaAdmin/api/operationstatus");
            
                HttpWebRequest httpWebRequest = CreateHttpWebRequest(operationUri, "POST");

                string jsonString = string.Empty;

                MemoryStream memStream = new MemoryStream();

                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(OperationStatus));

                serializer.WriteObject(memStream, operationStatus);

                memStream.Position = 0;

                StreamReader sr = new StreamReader(memStream);

                jsonString = sr.ReadToEnd();

                sr.Close();

                Byte[] postData = Encoding.UTF8.GetBytes(jsonString);

                httpWebRequest.ContentLength = postData.Length;

                using (Stream requestStream = httpWebRequest.GetRequestStream())
                {
                    requestStream.Write(postData, 0, postData.Length);
                }

                string jsonResponse = string.Empty;
        
                using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse())
                {
                    opsStatus = serializer.ReadObject(response.GetResponseStream()) as OperationStatus;

                    response.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error: {0}\n{1}", ex.Message,
                                  ex.InnerException != null ? ex.InnerException.Message : string.Empty));

                opsStatus = null;
            }

            return opsStatus;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.Clear();

            String requestId = string.Empty;

            try
            {
                string subscriptionId = "e57cc5fa-5cf7-41c0-a33c-3adaf2944c4a";
                string serviceName = "commandlinetest";
                string label = "Hosted Service Test";
                string deploymentName = "TestDeployment";
                string deploymentSlot = "staging";
                string certificateFilePath = @"C:\Development\Certificates\BermudaAdminCertificate.cer";
                int instanceCount = 1;

                requestId = CreateDeployment(subscriptionId, serviceName,
                                             label, deploymentName, deploymentSlot, 
                                             certificateFilePath, instanceCount);

                if (string.IsNullOrWhiteSpace(requestId) != true &&
                    requestId != "\"\"")
                {
                    OperationStatus opsStatus = new OperationStatus()
                    {
                        SubscriptionId = subscriptionId,
                        RequestId = requestId.Replace("\"", ""),
                        CertificateBytes = GetCertificateBytes(certificateFilePath).ToList<Byte>(),
                        ResponseString = "",
                        Status = "InProgress"
                    };

                    while (opsStatus.Status == "InProgress")
                    {
                        opsStatus = GetOperationStatus(opsStatus);

                        Console.WriteLine(opsStatus.Status);

                        Thread.Sleep(1500);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error: {0}\n{1}", ex.Message,
                                  ex.InnerException != null ? ex.InnerException.Message : string.Empty));
            }

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Please press a key to exit . . .");

            Console.WriteLine();
            Console.WriteLine();

            Console.ReadKey();
        }
Esempio n. 3
0
        static OperationStatus GetOperationStatus(OperationStatus operationStatus)
        {
            try
            {
                DeploymentHelper deploymentHelper = new DeploymentHelper();

                string status = string.Empty;

                string responseString = deploymentHelper.GetOperationStatus(operationStatus.SubscriptionId, 
                                                                            operationStatus.CertificateBytes,
                                                                            operationStatus.RequestId, out status);

                operationStatus.ResponseString = responseString;
                operationStatus.Status = status;
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("Error: {0}\n{1}", ex.Message,
                                  ex.InnerException != null ? ex.InnerException.Message : string.Empty));

                operationStatus = null;
            }

            return operationStatus;
        }