Ejemplo n.º 1
0
 /// <summary>
 /// Create a new website.
 /// </summary>
 /// <param name="webspaceName">Web space to create site in.</param>
 /// <param name="siteToCreate">Details about the site to create.</param>
 /// <param name="slot">The slot name.</param>
 /// <returns>The created site object</returns>
 public Utilities.Site CreateWebsite(string webspaceName, Utilities.SiteWithWebSpace siteToCreate, string slot)
 {
     siteToCreate.Name = SetWebsiteName(siteToCreate.Name, slot);
     string[] hostNames = { GetHostName(siteToCreate.Name, slot) };
     siteToCreate.HostNames = hostNames;
     return CreateWebsite(webspaceName, siteToCreate);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Update the set of host names for a website slot.
        /// </summary>
        /// <param name="site">The website name.</param>
        /// <param name="hostNames">The new host names.</param>
        /// <param name="slot">The website slot name.</param>
        public void UpdateWebsiteHostNames(Utilities.Site site, IEnumerable<string> hostNames, string slot)
        {
            site.Name = SetWebsiteName(site.Name, slot);

            UpdateWebsiteHostNames(site, hostNames);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a new website in production.
        /// </summary>
        /// <param name="webspaceName">Web space to create site in.</param>
        /// <param name="siteToCreate">Details about the site to create.</param>
        /// <returns>The created site object</returns>
        private Utilities.Site CreateWebsite(string webspaceName, Utilities.SiteWithWebSpace siteToCreate)
        {
            var options = new WebSiteCreateParameters
            {
                Name = siteToCreate.Name,
                WebSpace = new WebSiteCreateParameters.WebSpaceDetails
                {
                    GeoRegion = siteToCreate.WebSpaceToCreate.GeoRegion,
                    Name = siteToCreate.WebSpaceToCreate.Name,
                    Plan = siteToCreate.WebSpaceToCreate.Plan
                },
                ServerFarm = string.Empty
            };

            var response = WebsiteManagementClient.WebSites.Create(webspaceName, options);
            return response.WebSite.ToSite();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the set of host names for a website.
        /// </summary>
        /// <param name="site">The site name.</param>
        /// <param name="hostNames">The new host names.</param>
        public void UpdateWebsiteHostNames(Utilities.Site site, IEnumerable<string> hostNames)
        {
            var update = new WebSiteUpdateParameters();
            foreach (var name in hostNames)
            {
                update.HostNames.Add(name);
            }

            WebsiteManagementClient.WebSites.Update(site.WebSpace, site.Name, update);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Update the website slot configuration
 /// </summary>
 /// <param name="name">The website name</param>
 /// <param name="newConfiguration">The website configuration object containing updates.</param>
 /// <param name="slot">The website slot name</param>
 public void UpdateWebsiteConfiguration(string name, Utilities.SiteConfig newConfiguration, string slot)
 {
     name = SetWebsiteName(name, slot);
     UpdateWebsiteConfiguration(name, newConfiguration);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Update the website configuration
        /// </summary>
        /// <param name="name">The website name</param>
        /// <param name="newConfiguration">The website configuration object containing updates.</param>
        public void UpdateWebsiteConfiguration(string name, Utilities.SiteConfig newConfiguration)
        {
            Utilities.Site website = GetWebsite(name);
            WebsiteManagementClient.WebSites.UpdateConfiguration(website.WebSpace, name,
                newConfiguration.ToConfigUpdateParameters());

            if (newConfiguration.SlotStickyAppSettingNames != null
                || newConfiguration.SlotStickyConnectionStringNames != null)
            {
                WebsiteManagementClient.WebSites.UpdateSlotConfigNames(website.WebSpace, name,
                    newConfiguration.ToSlotConfigNamesUpdate());
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Updates a website compute mode.
 /// </summary>
 /// <param name="websiteToUpdate">The website to update</param>
 public void UpdateWebsiteComputeMode(Utilities.Site websiteToUpdate)
 {
     WebsiteManagementClient.WebSites.Update(
         websiteToUpdate.WebSpace,
         websiteToUpdate.Name,
         new WebSiteUpdateParameters
         {
             // Set the following 3 collection properties to null since by default they are empty lists,
             // which will clear the corresponding settings of the web site, thus results in a 404 when browsing the web site.
             HostNames = null,
             HostNameSslStates = null,
             ServerFarm = null
         });
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Sets a connection string for a website.
        /// </summary>
        /// <param name="name">Name of the website.</param>
        /// <param name="key">Connection string key.</param>
        /// <param name="value">Value for the connection string.</param>
        /// <param name="connectionStringType">Type of connection string.</param>
        public void SetConnectionString(string name, string key, string value, Utilities.DatabaseType connectionStringType)
        {
            Utilities.Site website = GetWebsite(name);

            var update = WebsiteManagementClient.WebSites.GetConfiguration(website.WebSpace, website.Name).ToUpdate();

            var csToUpdate = update.ConnectionStrings.FirstOrDefault(cs => cs.Name.Equals(key, StringComparison.OrdinalIgnoreCase));
            if (csToUpdate == null)
            {
                csToUpdate = new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                {
                    ConnectionString = value,
                    Name = key,
                    Type = (ConnectionStringType)Enum.Parse(typeof(ConnectionStringType), connectionStringType.ToString(), ignoreCase: true),
                };
                update.ConnectionStrings.Add(csToUpdate);
            }
            else
            {
                csToUpdate.ConnectionString = value;
                csToUpdate.Type = (ConnectionStringType)Enum.Parse(typeof(ConnectionStringType), connectionStringType.ToString(), ignoreCase: true);
            }

            WebsiteManagementClient.WebSites.UpdateConfiguration(website.WebSpace, website.Name, update);
        }