Пример #1
0
        static void Main(string[] args)
        {
            if (!CheckIfConfigsAreReplaced())
            {
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
                return;
            }

            var austinManagementService = new AustinManagementProxy(new Uri(ConfigurationManager.AppSettings["AustinManagementUrl"]));

            string serviceInstanceName = ConfigurationManager.AppSettings["HostedServiceName"];

            Console.WriteLine("Starting the StreamInsight service delete process for service '{0}'.", serviceInstanceName);
            Console.WriteLine("This can take around 5min. ");
            Console.WriteLine();

            try
            {
                austinManagementService.Delete(serviceInstanceName);

                // Wait for delete to finish
                Console.Write("Delete request submitted, waiting for it to finish.");
                DeleteStatusResponse deleteStatus = austinManagementService.GetDeleteStatus(serviceInstanceName);
                while (deleteStatus.Status != "Completed" && deleteStatus.Status != "Failed")
                {
                    Console.Write(".");
                    Thread.Sleep(TimeSpan.FromSeconds(5));
                    deleteStatus = austinManagementService.GetDeleteStatus(serviceInstanceName);
                }

                Console.WriteLine();

                if (deleteStatus.Status == "Completed")
                {
                    Console.WriteLine("Delete succeeded.");
                }
                else
                {
                    Console.WriteLine("Delete service failed. Error message: {0}", deleteStatus.Message);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (!CheckIfConfigsAreReplaced())
            {
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
                return;
            }

            // The provisioning service uses a REST API, which we are wrapping in this sample in a proxy class for convenience.
            var austinManagementService = new AustinManagementProxy(new Uri(ConfigurationManager.AppSettings["AustinManagementUrl"]));

            var beginTime = DateTime.Now;

            try
            {
                string hostedService = ConfigurationManager.AppSettings["HostedServiceName"];

                ServiceInformation serviceInfo = null;

                // The Austin instance will have the same name as the Azure hosted service it is hosted in.
                // Check if an Austin instance with this name already exists
                Console.WriteLine("Checking for existence of Austin instance '{0}'...", hostedService);

                try
                {
                    // If the service doesn't exist, we get an 'endpoint not found' exception.
                    // Bubble up all other exceptions.
                    serviceInfo = austinManagementService.GetServiceInformation(hostedService);
                }
                catch (EndpointNotFoundException) { }

                // If no instance with this name exists, provision it.
                if (serviceInfo == null)
                {
                    Console.WriteLine("Austin instance {0} does not exist. Proceeding with provisioning.", hostedService);
                    Console.WriteLine();

                    Provision(ref austinManagementService, hostedService);
                }
                else
                {
                    Console.WriteLine("Austin instance {0} already exists.", hostedService);
                    Console.WriteLine("Version of current service: {0}", serviceInfo.StreamInsightVersion);
                    Console.WriteLine("User resources version: {0}", serviceInfo.UserResourcesVersion);
                    Console.WriteLine("Service endpoints:");

                    foreach (KeyValuePair<string, string> item in serviceInfo.StreamInsightUris)
                    {
                        Console.WriteLine("  {0}: {1}", item.Key, item.Value);
                    }

                    if (String.Compare(serviceInfo.StreamInsightVersion, "20120622221345.0382744") < 0)
                    {
                        Console.WriteLine();
                        Console.WriteLine("A more recent Austin version is available. Please delete your service and re-provision.");
                    }
                }

                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            var elapsedTime = DateTime.Now - beginTime;

            Console.WriteLine("The process took {0}h {1}m {2}s to finish.", elapsedTime.Hours, elapsedTime.Minutes, elapsedTime.Seconds);
            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
Пример #3
0
        /// <summary>
        /// Provisioning of a new Austin instance in Windows Azure.
        /// </summary>
        /// <param name="proxy">Austin management web service proxy.</param>
        /// <param name="serviceInstanceName">Name of the Azure hosted service to host Austin.</param>
        private static void Provision(ref AustinManagementProxy proxy, string serviceInstanceName)
        {
            #region hosted service credentials
            // Credentials needed to access the hosted service in the user's subscription.
            // note that this is the provisioning model in the Austin CTP. Eventually, this will go away when Austin
            // becomes a multi-tenancy service.
            ServiceCredentials siCred = new ServiceCredentials();
            siCred.StorageAccountKey = ConfigurationManager.AppSettings["StorageAccountKey"];
            siCred.StorageAccountName = ConfigurationManager.AppSettings["StorageAccountName"];
            siCred.SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"];
            siCred.Certificate = CertificateHelper.GetBase64StringEncodedCertFromFilePath(ConfigurationManager.AppSettings["ServiceManagementCertificateFilePath"]);
            siCred.CertificatePassword = ConfigurationManager.AppSettings["ServiceManagementCertificatePassword"];
            #endregion

            string computeVmSize = ConfigurationManager.AppSettings["ComputeVmSize"];
            var ingressConfig = new IngressConfiguration
                {
                    VmSize = ConfigurationManager.AppSettings["IngressVmSize"],
                    NumberOfInstances = int.Parse(ConfigurationManager.AppSettings["NumberOfIngressInstances"]),
                    Endpoints = new List<IngressEndpoint>
                        {
                            new IngressEndpoint
                                {
                                    Protocol = ConfigurationManager.AppSettings["IngressProtocol"],
                                    Port = int.Parse(ConfigurationManager.AppSettings["IngressEndpointPort"])
                                }
                        }
                };

            Console.WriteLine("Starting the Austin service provisioning process.");
            Console.WriteLine("This step wraps an Azure hosted service deployment and can therefore take around 15min.");
            Console.WriteLine("You can also check the provisioning status on the Azure management portal.");
            Console.WriteLine("If the provisioning process does not exit even after the instance shows \"Ready\" in the management portal, you can safely break.");
            Console.WriteLine();

            // Create the Austin Instance. This is a REST API and all communication happens over HTTP
            // The API is async and will return after validating the input and copying some files
            // The response contains the status after validation and the URI of the Austin instance
            // that will be provisioned.
            CreateResponse response = proxy.Provision(serviceInstanceName, null, siCred, computeVmSize, ingressConfig);

            Console.WriteLine("Provisioning of Austin into Azure Hosted Service '{0}' kicked off.", serviceInstanceName);

            Console.Write("The provisioning call returned client and service certificates. ");
            Console.Write("They will now be installed into the machine's store, in order to enable clients to connect to the Austin instance. ");
            Console.WriteLine("This only succeeds if the app is run as admin!");
            AddServiceAndClientCertsToStore(response);

            // Get the status of the provisioning operation
            string newStatusCode = proxy.GetProvisioningStatus(serviceInstanceName).StatusCode;
            string statusCode = null;

            // Check status until provisioning succeeded.
            while ((newStatusCode != "Ready") && (newStatusCode != "Failed"))
            {
                if (newStatusCode != statusCode)
                {
                    Console.WriteLine();
                    Console.Write(newStatusCode + " ");
                    statusCode = newStatusCode;
                }
                else
                {
                    Console.Write(".");
                }

                // Azure takes around 15 minutes to provision and deploy any new service.
                // So keep checking until the provisioned Austin instances is ready for connection
                System.Threading.Thread.Sleep(5000);
                newStatusCode = proxy.GetProvisioningStatus(serviceInstanceName).StatusCode;
            }

            Console.WriteLine();

            if (newStatusCode == "Ready")
            {
                //This is the URI for the Austin instance that was provisioned by the provisioning service
                string siInstanceUri = response.StreamInsightUris["StreamInsightManagementEndpoint"];

                Console.WriteLine("Provisioning succeeded.");
                Console.WriteLine();

                Console.WriteLine("Service endpoints:");

                var serviceInfo = proxy.GetServiceInformation(serviceInstanceName);

                foreach (KeyValuePair<string, string> item in serviceInfo.StreamInsightUris)
                {
                    Console.WriteLine("  {0}: {1}", item.Key, item.Value);
                }
            }
            else
            {
                Console.WriteLine("Provisioning Failed!");
            }
        }