/// <summary>
        /// Add default documents
        /// </summary>
        /// <param name="documentNames">Collection of default document names</param>
        /// <returns>AppServiceWebAppConfiguration</returns>
        public AppServiceWebAppConfiguration UseDefaultDocument(params string[] documentNames)
        {
            if (DefaultDocuments == null)
            {
                DefaultDocuments = new List <string>();
            }

            foreach (string doc in documentNames)
            {
                if (!DefaultDocuments.Contains(doc))
                {
                    DefaultDocuments.Add(doc);
                }
            }

            return(this);
        }
Exemplo n.º 2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            WebsitesClient = WebsitesClient ?? new WebsitesClient(CurrentSubscription, WriteDebug);
            string suffix = WebsitesClient.GetWebsiteDnsSuffix();

            Site       website       = null;
            SiteConfig websiteConfig = null;

            InvokeInOperationContext(() =>
            {
                try
                {
                    website       = RetryCall(s => Channel.GetSite(s, Name, null));
                    websiteConfig = RetryCall(s => Channel.GetSiteConfig(s, website.WebSpace, Name));
                }
                catch (CommunicationException ex)
                {
                    WriteErrorDetails(ex);
                }
            });

            if (website == null)
            {
                throw new Exception(string.Format(Resources.InvalidWebsite, Name));
            }

            bool           changes             = false;
            SiteWithConfig websiteConfigUpdate = new SiteWithConfig(website, websiteConfig);

            if (SiteWithConfig != null)
            {
                websiteConfigUpdate = SiteWithConfig;
                changes             = true;
            }

            if (NumberOfWorkers != null && !NumberOfWorkers.Equals(websiteConfig.NumberOfWorkers))
            {
                changes = true;
                websiteConfigUpdate.NumberOfWorkers = NumberOfWorkers;
            }

            if (DefaultDocuments != null && !DefaultDocuments.Equals(websiteConfig.DefaultDocuments))
            {
                changes = true;
                websiteConfigUpdate.DefaultDocuments = DefaultDocuments;
            }

            if (NetFrameworkVersion != null && !NetFrameworkVersion.Equals(websiteConfig.NetFrameworkVersion))
            {
                changes = true;
                websiteConfigUpdate.NetFrameworkVersion = NetFrameworkVersion;
            }

            if (PhpVersion != null && !PhpVersion.Equals(websiteConfig.PhpVersion))
            {
                changes = true;
                websiteConfigUpdate.PhpVersion = PhpVersion;
            }

            if (RequestTracingEnabled != null && !RequestTracingEnabled.Equals(websiteConfig.RequestTracingEnabled))
            {
                changes = true;
                websiteConfigUpdate.RequestTracingEnabled = RequestTracingEnabled;
            }

            if (HttpLoggingEnabled != null && !HttpLoggingEnabled.Equals(websiteConfig.HttpLoggingEnabled))
            {
                changes = true;
                websiteConfigUpdate.HttpLoggingEnabled = HttpLoggingEnabled;
            }

            if (DetailedErrorLoggingEnabled != null && !DetailedErrorLoggingEnabled.Equals(websiteConfig.DetailedErrorLoggingEnabled))
            {
                changes = true;
                websiteConfigUpdate.DetailedErrorLoggingEnabled = DetailedErrorLoggingEnabled;
            }

            if (AppSettings != null && !AppSettings.Equals(websiteConfig.AppSettings))
            {
                changes = true;
                websiteConfigUpdate.AppSettings = AppSettings;
            }

            if (Metadata != null && !Metadata.Equals(websiteConfig.Metadata))
            {
                changes = true;
                websiteConfigUpdate.Metadata = Metadata;
            }

            if (ConnectionStrings != null && !ConnectionStrings.Equals(websiteConfig.ConnectionStrings))
            {
                changes = true;
                websiteConfigUpdate.ConnectionStrings = ConnectionStrings;
            }

            if (HandlerMappings != null && !HandlerMappings.Equals(websiteConfig.HandlerMappings))
            {
                changes = true;
                websiteConfigUpdate.HandlerMappings = HandlerMappings;
            }

            bool siteChanges   = false;
            Site websiteUpdate = new Site
            {
                Name      = Name,
                HostNames = new[] { string.Format("{0}.{1}", Name, suffix) }
            };

            if (HostNames != null)
            {
                siteChanges = true;
                List <string> newHostNames = new List <string> {
                    string.Format("{0}.{1}", Name, suffix)
                };
                newHostNames.AddRange(HostNames);
                websiteUpdate.HostNames = newHostNames.ToArray();
            }

            if (changes)
            {
                InvokeInOperationContext(() =>
                {
                    try
                    {
                        RetryCall(s => Channel.UpdateSiteConfig(s, website.WebSpace, Name, websiteConfigUpdate.GetSiteConfig()));
                    }
                    catch (CommunicationException ex)
                    {
                        WriteErrorDetails(ex);
                    }
                });
            }

            if (siteChanges)
            {
                InvokeInOperationContext(() =>
                {
                    try
                    {
                        RetryCall(s => Channel.UpdateSite(s, website.WebSpace, Name, websiteUpdate));
                    }
                    catch (CommunicationException ex)
                    {
                        WriteErrorDetails(ex);
                    }
                });
            }

            if (PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }
Exemplo n.º 3
0
 public Task <IDocumentationDocument[]> GetDocumentationDefaultDocuments(string documentType = "")
 {
     return(Task.FromResult(DefaultDocuments?.ToArray()));
 }