private void WriteWebsite(Site websiteObject)
        {
            SiteConfig config = WebsitesClient.GetWebsiteConfiguration(websiteObject.Name);

            var diagnosticSettings = new DiagnosticsSettings();

            try
            {
                diagnosticSettings = WebsitesClient.GetApplicationDiagnosticsSettings(websiteObject.Name);
            }
            catch
            {
                // Ignore exception and use default values
            }

            WebsiteInstance[] instanceIds;
            try
            {
                instanceIds = WebsitesClient.ListWebsiteInstances(websiteObject.WebSpace, websiteObject.Name);
            }
            catch
            {
                // TODO: Temporary workaround for issue where slots are not supported with this API (yet).
                instanceIds = new WebsiteInstance[0];
            }

            WriteObject(new SiteWithConfig(websiteObject, config, diagnosticSettings, instanceIds), false);
        }
Esempio n. 2
0
 private void CreateSite(WebSpace webspace, SiteWithWebSpace website)
 {
     try
     {
         WebsitesClient.CreateWebsite(webspace.Name, website);
         Cache.AddSite(CurrentSubscription.SubscriptionId, website);
         SiteConfig websiteConfiguration = WebsitesClient.GetWebsiteConfiguration(Name);
         WriteObject(new SiteWithConfig(website, websiteConfiguration));
     }
     catch (CloudException ex)
     {
         if (SiteAlreadyExists(ex) && (Git || GitHub))
         {
             // Handle conflict - it's ok to attempt to use cmdlet on an
             // existing website if you're updating the source control stuff.
             WriteWarning(ex.Message);
         }
         else if (HostNameValidationFailed(ex))
         {
             WriteExceptionError(new Exception(Resources.InvalidHostnameValidation));
         }
         else if (BadPlan(ex))
         {
             throw new EndpointNotFoundException();
         }
         else
         {
             WriteExceptionError(new Exception(ex.Message));
         }
     }
 }
        private Site CreateSite(WebSpace webspace, SiteWithWebSpace website)
        {
            Site createdWebsite = null;

            try
            {
                if (WebsitesClient.WebsiteExists(website.Name) && !string.IsNullOrEmpty(Slot))
                {
                    createdWebsite = WebsitesClient.GetWebsite(website.Name);

                    // Make sure that the website is in Standard mode
                    if (createdWebsite.ComputeMode == WebSiteComputeMode.Dedicated)
                    {
                        WebsitesClient.CreateWebsite(webspace.Name, website, Slot);
                    }
                    else
                    {
                        throw new Exception("Can not create slot in a website not in Standard mode");
                    }
                }
                else
                {
                    WebsitesClient.CreateWebsite(webspace.Name, website, null);
                }

                createdWebsite = WebsitesClient.GetWebsite(website.Name);

                Cache.AddSite(CurrentContext.Subscription.Id.ToString(), createdWebsite);
                SiteConfig websiteConfiguration = WebsitesClient.GetWebsiteConfiguration(createdWebsite.Name, Slot);
                WriteObject(new SiteWithConfig(createdWebsite, websiteConfiguration));
            }
            catch (CloudException ex)
            {
                if (SiteAlreadyExists(ex) && (Git || GitHub))
                {
                    // Handle conflict - it's ok to attempt to use cmdlet on an
                    // existing website if you're updating the source control stuff.
                    WriteWarning(ex.Message);
                    createdWebsite = WebsitesClient.GetWebsite(website.Name, null);
                }
                else if (HostNameValidationFailed(ex))
                {
                    WriteExceptionError(new Exception(Resources.InvalidHostnameValidation));
                }
                else if (BadPlan(ex))
                {
                    throw new EndpointNotFoundException();
                }
                else
                {
                    WriteExceptionError(new Exception(ex.Message));
                }
            }

            return(createdWebsite);
        }
        private void WriteWebsite(Site websiteObject)
        {
            SiteConfig config = WebsitesClient.GetWebsiteConfiguration(websiteObject.Name);

            var diagnosticSettings = new DiagnosticsSettings();

            try
            {
                diagnosticSettings = WebsitesClient.GetApplicationDiagnosticsSettings(websiteObject.Name);
            }
            catch
            {
                // Ignore exception and use default values
            }

            WriteObject(new SiteWithConfig(websiteObject, config, diagnosticSettings), false);
        }
Esempio n. 5
0
        public override void ExecuteCmdlet()
        {
            // Get current config
            website = WebsitesClient.GetWebsite(Name, Slot);
            siteConfig = WebsitesClient.GetWebsiteConfiguration(Name, Slot);

            // Update the configuration
            if (siteConfig.RemoteDebuggingEnabled.Value)
            {
                siteConfig.RemoteDebuggingEnabled = false;
                WebsitesClient.UpdateWebsiteConfiguration(Name, siteConfig, Slot);
            }

            if (PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }
Esempio n. 6
0
        private void GetByName()
        {
            Do(() =>
            {
                Site websiteObject = WebsitesClient.GetWebsite(Name);
                SiteConfig config  = WebsitesClient.GetWebsiteConfiguration(Name);
                Cache.AddSite(CurrentSubscription.SubscriptionId, websiteObject);

                var diagnosticSettings = new DiagnosticsSettings();
                try
                {
                    diagnosticSettings = WebsitesClient.GetApplicationDiagnosticsSettings(Name);
                }
                catch
                {
                    // Ignore exception and use default values
                }

                WriteObject(new SiteWithConfig(websiteObject, config, diagnosticSettings), false);
            });
        }
Esempio n. 7
0
 private void GetCurrentSiteState()
 {
     website           = WebsitesClient.GetWebsite(Name, Slot);
     currentSiteConfig = WebsitesClient.GetWebsiteConfiguration(Name, Slot);
 }