/// <summary>
        /// Provisions a new Austin service in the target hosted service
        /// It is a POST method that adds a new service.
        /// </summary>
        /// <param name="serviceName">Name of the Azure hosted service. This must be already created.</param>
        /// <param name="version">Version of Austin to install. If left empty or null, provisioning defaults to the latest version.</param>
        /// <param name="credentials">Credentials to access the user's hosted service and storage account.</param>
        /// <param name="computeVmSize">Size of the compute vm.</param>
        /// <param name="ingressConfig">Ingress pool configuration.</param>
        /// <returns>
        /// A provisioning response, containing information about how to access the new Austin instance.
        /// </returns>
        public CreateResponse Provision(string serviceName, string version, ServiceCredentials credentials, string computeVmSize, IngressConfiguration ingressConfig)
        {
            CreateRequest provRequest = new CreateRequest();

            provRequest.ServiceInstanceName  = serviceName;
            provRequest.Credentials          = credentials;
            provRequest.Version              = version;
            provRequest.ComputeVmSize        = computeVmSize;
            provRequest.IngressConfiguration = ingressConfig;

            Uri provisioningUri = new Uri(_austinManagementUri, "HostedServices");

            var apiProxy = new RestApiProxy <CreateRequest, CreateResponse>(provisioningUri);

            return(apiProxy.Send(provRequest, HttpMethod.Post));
        }
Example #2
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!");
            }
        }
        /// <summary>
        /// Provisions a new Austin service in the target hosted service
        /// It is a POST method that adds a new service.
        /// </summary>
        /// <param name="serviceName">Name of the Azure hosted service. This must be already created.</param>
        /// <param name="version">Version of Austin to install. If left empty or null, provisioning defaults to the latest version.</param>
        /// <param name="credentials">Credentials to access the user's hosted service and storage account.</param>
        /// <param name="computeVmSize">Size of the compute vm.</param>
        /// <param name="ingressConfig">Ingress pool configuration.</param>
        /// <returns>
        /// A provisioning response, containing information about how to access the new Austin instance.
        /// </returns>
        public CreateResponse Provision(string serviceName, string version, ServiceCredentials credentials, string computeVmSize, IngressConfiguration ingressConfig)
        {
            CreateRequest provRequest = new CreateRequest();

            provRequest.ServiceInstanceName = serviceName;
            provRequest.Credentials = credentials;
            provRequest.Version = version;
            provRequest.ComputeVmSize = computeVmSize;
            provRequest.IngressConfiguration = ingressConfig;

            Uri provisioningUri = new Uri(_austinManagementUri, "HostedServices");

            var apiProxy = new RestApiProxy<CreateRequest, CreateResponse>(provisioningUri);

            return apiProxy.Send(provRequest, HttpMethod.Post);
        }