public void 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())
            {
                if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
                {
                    if (!String.IsNullOrEmpty(Config.AADTenantId()))
                    {
                        webConfig.UpdateXElement("Aad.AADTenantId", Config.AADTenantId());
                    }

                    if (!String.IsNullOrEmpty(scaleUnit.AzureStorageConnectionString))
                    {
                        webConfig.UpdateXElement("AzureStorage.StorageConnectionString", scaleUnit.AzureStorageConnectionString);
                    }

                    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.AddKey("ScaleUnit.InstanceID", scaleUnit.ScaleUnitId);
                webConfig.AddKey("ScaleUnit.Enabled", "true");
                webConfig.AddKey("DbSync.TriggersEnabled", "true");
            }

            WifServiceConfig.Update();

            if (Config.UseSingleOneBox())
            {
                CreateScaleUnitBatchService(scaleUnit);
            }
        }
        public override void Run()
        {
            using (var webConfig = new WebConfig())
            {
                if (Config.EnvironmentType() == EnvironmentType.VHD)
                {
                    if (!String.IsNullOrEmpty(Config.AADTenantId()))
                    {
                        webConfig.UpdateXElement("Aad.AADTenantId", Config.AADTenantId());
                    }

                    if (!String.IsNullOrEmpty(Config.AzureStorageConnectionString()))
                    {
                        webConfig.UpdateXElement("AzureStorage.StorageConnectionString", Config.AzureStorageConnectionString());
                    }

                    webConfig.UpdateXElement("Infrastructure.FullyQualifiedDomainName", Config.ScaleUnitDomain());
                    webConfig.UpdateXElement("Infrastructure.HostName", Config.ScaleUnitDomain());
                    webConfig.UpdateXElement("Infrastructure.HostedServiceName", Config.ScaleUnitUrlName());

                    string scaleUnitUrl = Config.ScaleUnitAosEndpoint() + "/";
                    webConfig.UpdateXElement("Infrastructure.HostUrl", scaleUnitUrl);
                    webConfig.UpdateXElement("Infrastructure.SoapServicesUrl", scaleUnitUrl);
                }

                webConfig.AddKey("ScaleUnit.InstanceID", Config.ScaleUnitId());
                webConfig.AddKey("ScaleUnit.Enabled", "true");
                webConfig.AddKey("DbSync.TriggersEnabled", "true");
            }

            WifServiceConfig.Update();

            if (Config.EnvironmentType() == EnvironmentType.VHD)
            {
                // Update hosts file
                using (var hosts = new Hosts())
                {
                    hosts.AddMapping("127.0.0.1", Config.ScaleUnitDomain());
                    hosts.AddMapping(Config.HubIp(), Config.HubDomain());
                }

                // Configure IIS binding
                using (ServerManager manager = new ServerManager())
                {
                    Site site = manager.Sites["AOSService"];
                    site.Bindings.Clear();
                    site.Bindings.Add("*:443:" + Config.ScaleUnitDomain(), "https");

                    manager.CommitChanges();
                }
            }
        }
        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);
        }
        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 void Run()
        {
            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            using (var webConfig = new WebConfig())
            {
                if (scaleUnit.EnvironmentType == EnvironmentType.VHD)
                {
                    if (!String.IsNullOrEmpty(Config.AADTenantId()))
                    {
                        webConfig.UpdateXElement("Aad.AADTenantId", Config.AADTenantId());
                    }

                    if (!String.IsNullOrEmpty(scaleUnit.AzureStorageConnectionString))
                    {
                        webConfig.UpdateXElement("AzureStorage.StorageConnectionString", scaleUnit.AzureStorageConnectionString);
                    }

                    webConfig.UpdateXElement("Infrastructure.StartStorageEmulator", "false");
                }

                webConfig.AddKey("ScaleUnit.InstanceID", scaleUnit.ScaleUnitId);
                webConfig.AddKey("ScaleUnit.Enabled", "true");
                webConfig.AddKey("DbSync.TriggersEnabled", "true");
            }

            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());
            }
        }