public Task Run()
        {
            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            using (var webConfig = new WebConfig())
            {
                SharedWebConfig.Configure(webConfig);

                if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
                {
                    webConfig.UpdateXElement("Infrastructure.StartStorageEmulator", "false");

                    webConfig.AddValidAudiences(scaleUnit);
                }
            }

            if (Config.UseSingleOneBox())
            {
                // Update hosts file
                using (var hosts = new Hosts())
                {
                    hosts.AddMapping(scaleUnit.IpAddress, scaleUnit.DomainSafe());
                }

                // Update IIS binding
                IISAdministrationHelper.CreateSite(
                    siteName: scaleUnit.SiteName(),
                    siteRoot: scaleUnit.SiteRoot(),
                    bindingInformation: scaleUnit.IpAddress + ":443:" + scaleUnit.DomainSafe(),
                    certSubject: scaleUnit.DomainSafe(),
                    appPoolName: scaleUnit.AppPoolName());
            }

            return(Task.CompletedTask);
        }
        public Task Run()
        {
            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
            {
                // Update hosts file
                using (var hosts = new Hosts())
                {
                    hosts.AddMapping(scaleUnit.IpAddress, scaleUnit.DomainSafe());
                    hosts.AddMapping(Config.HubScaleUnit().IpAddress, Config.HubScaleUnit().DomainSafe());
                }

                IISAdministrationHelper.CreateSite(
                    siteName: scaleUnit.SiteName(),
                    siteRoot: scaleUnit.SiteRoot(),
                    bindingInformation: scaleUnit.IpAddress + ":443:" + scaleUnit.DomainSafe(),
                    certSubject: scaleUnit.DomainSafe(),
                    appPoolName: scaleUnit.AppPoolName());
            }

            using (var webConfig = new WebConfig())
            {
                SharedWebConfig.Configure(webConfig);

                if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
                {
                    webConfig.UpdateXElement("Infrastructure.FullyQualifiedDomainName", scaleUnit.DomainSafe());
                    webConfig.UpdateXElement("Infrastructure.HostName", scaleUnit.DomainSafe());
                    webConfig.UpdateXElement("Infrastructure.HostedServiceName", scaleUnit.ScaleUnitUrlName());

                    string scaleUnitUrl = scaleUnit.Endpoint() + "/";
                    webConfig.UpdateXElement("Infrastructure.HostUrl", scaleUnitUrl);
                    webConfig.UpdateXElement("Infrastructure.SoapServicesUrl", scaleUnitUrl);

                    webConfig.UpdateXElement("DataAccess.Database", scaleUnit.AxDbName);

                    webConfig.AddValidAudiences(scaleUnit);
                }
            }

            WifServiceConfig.Update();

            if (Config.UseSingleOneBox())
            {
                CreateScaleUnitBatchService(scaleUnit);
            }

            return(Task.CompletedTask);
        }