ShouldUseDeploymentSlot() static private method

static private ShouldUseDeploymentSlot ( string webSiteName, string slotName, string &qualifiedSiteName ) : bool
webSiteName string
slotName string
qualifiedSiteName string
return bool
示例#1
0
        public BackupItem BackupSite(string resourceGroupName, string webSiteName, string slotName,
                                     BackupRequest request)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                var backup = WrappedWebsitesClient.WebApps().BackupSlot(resourceGroupName, webSiteName, request, slotName);
                return(backup);
            }
            else
            {
                var backup = WrappedWebsitesClient.WebApps().Backup(resourceGroupName, webSiteName, request);
                return(backup);
            }
        }
        public void UpdateWebApp(string resourceGroupName, string location, string webAppName, string slotName, string appServicePlan)
        {
            var webSiteToUpdate = new Site()
            {
                ServerFarmId = appServicePlan,
                Location     = location
            };

            string qualifiedSiteName;

            if (CmdletHelpers.ShouldUseDeploymentSlot(webAppName, slotName, out qualifiedSiteName))
            {
                WrappedWebsitesClient.WebApps().CreateOrUpdateSiteSlot(resourceGroupName, webAppName, webSiteToUpdate, slotName);
            }
            else
            {
                webSiteToUpdate = WrappedWebsitesClient.WebApps().CreateOrUpdateSite(resourceGroupName, webAppName, webSiteToUpdate);
            }
        }
示例#3
0
        public PSSite GetWebApp(string resourceGroupName, string webSiteName, string slotName)
        {
            Site   site = null;
            string qualifiedSiteName;

            site = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName) ?
                   WrappedWebsitesClient.WebApps().GetSlot(resourceGroupName, webSiteName, slotName) :
                   WrappedWebsitesClient.WebApps().Get(resourceGroupName, webSiteName);

            GetWebAppConfiguration(resourceGroupName, webSiteName, slotName, site);
            PSSite psSite = new PSSite(site);
            var    AzureStorageAccounts = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName) ?
                                          GetAzureStorageAccounts(resourceGroupName, webSiteName, slotName, true) :
                                          GetAzureStorageAccounts(resourceGroupName, webSiteName, null, false);

            psSite.AzureStoragePath = AzureStorageAccounts?.Properties.ConvertToWebAppAzureStorageArray();

            return(psSite);
        }
        public string GetWebAppPublishingProfile(string resourceGroupName, string webSiteName, string slotName, string outputFile, string format)
        {
            string qualifiedSiteName;
            var    options = new CsmPublishingProfileOptions
            {
                Format = format
            };

            var publishingXml = (CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName) ?
                                 WrappedWebsitesClient.WebApps().ListPublishingProfileXmlWithSecretsSlot(resourceGroupName, webSiteName, options, slotName) :
                                 WrappedWebsitesClient.WebApps().ListPublishingProfileXmlWithSecrets(resourceGroupName, webSiteName, options));
            var doc = XDocument.Load(publishingXml, LoadOptions.None);

            if (outputFile != null)
            {
                doc.Save(outputFile, SaveOptions.OmitDuplicateNamespaces);
            }
            return(doc.ToString());
        }
示例#5
0
        private void GetWebAppConfiguration(string resourceGroupName, string webSiteName, string slotName, Site site)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            site.SiteConfig = (useSlot ?
                               WrappedWebsitesClient.WebApps().GetConfigurationSlot(resourceGroupName, webSiteName, slotName) :
                               WrappedWebsitesClient.WebApps().GetConfiguration(resourceGroupName, webSiteName)).ConvertToSiteConfig();
            try
            {
                var appSettings = useSlot ?
                                  WrappedWebsitesClient.WebApps().ListApplicationSettingsSlot(resourceGroupName, webSiteName, slotName) :
                                  WrappedWebsitesClient.WebApps().ListApplicationSettings(resourceGroupName, webSiteName);

                site.SiteConfig.AppSettings = appSettings.Properties.Select(s => new NameValuePair {
                    Name = s.Key, Value = s.Value
                }).ToList();

                var connectionStrings = useSlot ?
                                        WrappedWebsitesClient.WebApps().ListConnectionStringsSlot(resourceGroupName, webSiteName, slotName) :
                                        WrappedWebsitesClient.WebApps().ListConnectionStrings(resourceGroupName, webSiteName);

                site.SiteConfig.ConnectionStrings = connectionStrings
                                                    .Properties
                                                    .Select(s => new ConnStringInfo()
                {
                    Name             = s.Key,
                    ConnectionString = s.Value.Value,
                    Type             = s.Value.Type
                }).ToList();

                var azureStorageAccounts = useSlot ?
                                           WrappedWebsitesClient.WebApps().ListAzureStorageAccountsSlot(resourceGroupName, webSiteName, slotName) :
                                           WrappedWebsitesClient.WebApps().ListAzureStorageAccounts(resourceGroupName, webSiteName);

                site.SiteConfig.AzureStorageAccounts = azureStorageAccounts.Properties;
            }
            catch
            {
                //ignore if this call fails as it will for reader RBAC
            }
        }
        public RestoreResponse RestoreSite(string resourceGroupName, string webSiteName, string slotName,
                                           string backupId, RestoreRequest request)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                return(WrappedWebsitesClient.WebApps().RestoreSiteSlot(
                           resourceGroupName,
                           webSiteName,
                           backupId,
                           request,
                           slotName));
            }
            else
            {
                return(WrappedWebsitesClient.WebApps().RestoreSite(resourceGroupName, webSiteName, backupId, request));
            }
        }
示例#7
0
        public BackupItem GetSiteBackupStatus(string resourceGroupName, string webSiteName, string slotName, string backupId)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                return(WrappedWebsitesClient.WebApps().GetBackupStatusSlot(
                           resourceGroupName,
                           webSiteName,
                           backupId,
                           slotName));
            }
            else
            {
                return(WrappedWebsitesClient.WebApps().GetBackupStatus(
                           resourceGroupName,
                           webSiteName,
                           backupId));
            }
        }
        public BackupRequest UpdateWebAppBackupConfiguration(string resourceGroupName, string webSiteName,
                                                             string slotName, BackupRequest newSchedule)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                return(WrappedWebsitesClient.WebApps().UpdateSiteBackupConfigurationSlot(
                           resourceGroupName,
                           webSiteName,
                           newSchedule,
                           slotName));
            }
            else
            {
                return(WrappedWebsitesClient.WebApps().UpdateSiteBackupConfiguration(
                           resourceGroupName,
                           webSiteName,
                           newSchedule));
            }
        }
示例#9
0
        public Site UpdateHostNameSslState(string resourceGroupName, string webAppName, string slotName, string location, string hostName, SslState sslState, string thumbPrint)
        {
            Site   updateWebSite;
            string qualifiedSiteName;

            var shouldUseDeploymentSlot = CmdletHelpers.ShouldUseDeploymentSlot(webAppName, slotName, out qualifiedSiteName);

            var webappWithNewSslBinding = new Site
            {
                HostNameSslStates = new List <HostNameSslState> {
                    new HostNameSslState
                    {
                        Name       = hostName,
                        Thumbprint = thumbPrint,
                        ToUpdate   = true,
                        SslState   = sslState
                    }
                },
                Location = location
            };

            var webapp = GetWebApp(resourceGroupName, webAppName, slotName);

            webappWithNewSslBinding.Tags = webapp?.Tags;

            if (shouldUseDeploymentSlot)
            {
                updateWebSite = WrappedWebsitesClient.WebApps().CreateOrUpdateSlot(
                    resourceGroupName, webAppName, slot: slotName, siteEnvelope:
                    webappWithNewSslBinding);
            }
            else
            {
                updateWebSite = WrappedWebsitesClient.WebApps().CreateOrUpdate(
                    resourceGroupName, webAppName, siteEnvelope:
                    webappWithNewSslBinding);
            }
            return(updateWebSite);
        }
示例#10
0
        public Site CreateWebApp(string resourceGroupName, string webAppName, string slotName, string location, string serverFarmId, CloningInfo cloningInfo, string aseName, string aseResourceGroupName)
        {
            Site   createdWebSite = null;
            string qualifiedSiteName;
            var    profile = CreateHostingEnvironmentProfile(resourceGroupName, aseResourceGroupName, aseName);

            if (CmdletHelpers.ShouldUseDeploymentSlot(webAppName, slotName, out qualifiedSiteName))
            {
                createdWebSite = WrappedWebsitesClient.Sites.CreateOrUpdateSiteSlot(
                    resourceGroupName, webAppName, slot: slotName, siteEnvelope:
                    new Site
                {
                    SiteName     = qualifiedSiteName,
                    Location     = location,
                    ServerFarmId = serverFarmId,
                    CloningInfo  = cloningInfo,
                    HostingEnvironmentProfile = profile
                });
            }
            else
            {
                createdWebSite = WrappedWebsitesClient.Sites.CreateOrUpdateSite(
                    resourceGroupName, webAppName, siteEnvelope:
                    new Site
                {
                    SiteName     = qualifiedSiteName,
                    Location     = location,
                    ServerFarmId = serverFarmId,
                    CloningInfo  = cloningInfo,
                    HostingEnvironmentProfile = profile
                });
            }



            GetWebAppConfiguration(resourceGroupName, webAppName, slotName, createdWebSite);
            return(createdWebSite);
        }
        public void UpdateWebAppConfiguration(string resourceGroupName, string location, string webSiteName, string slotName, SiteConfig siteConfig = null, IDictionary <string, string> appSettings = null, IDictionary <string, ConnStringValueTypePair> connectionStrings = null)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                if (siteConfig != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteConfigSlot(
                        resourceGroupName,
                        webSiteName,
                        siteConfig,
                        slotName);
                }

                if (appSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteAppSettingsSlot(
                        resourceGroupName,
                        webSiteName,
                        new StringDictionary {
                        Location = location, Properties = appSettings
                    },
                        slotName);
                }

                if (connectionStrings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteConnectionStringsSlot(
                        resourceGroupName,
                        webSiteName,
                        new ConnectionStringDictionary {
                        Location = location, Properties = connectionStrings
                    },
                        slotName);
                }
            }
            else
            {
                if (siteConfig != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteConfig(resourceGroupName, webSiteName, siteConfig);
                }

                if (appSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteAppSettings(
                        resourceGroupName,
                        webSiteName,
                        new StringDictionary {
                        Location = location, Properties = appSettings
                    });
                }

                if (connectionStrings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateSiteConnectionStrings(
                        resourceGroupName,
                        webSiteName,
                        new ConnectionStringDictionary {
                        Location = location, Properties = connectionStrings
                    });
                }
            }
        }
示例#12
0
        public void UpdateWebAppConfiguration(string resourceGroupName, string location, string webSiteName, string slotName, SiteConfig siteConfig = null, IDictionary <string, string> appSettings = null, IDictionary <string, ConnStringValueTypePair> connectionStrings = null, AzureStoragePropertyDictionaryResource azureStorageSettings = null)
        {
            string qualifiedSiteName;
            var    useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName);

            if (useSlot)
            {
                if (appSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateApplicationSettingsSlot(
                        resourceGroupName,
                        webSiteName,
                        new StringDictionary {
                        Properties = appSettings
                    },
                        slotName);
                }

                if (siteConfig != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateConfigurationSlot(
                        resourceGroupName,
                        webSiteName,
                        siteConfig.ConvertToSiteConfigResource(),
                        slotName);
                }

                if (connectionStrings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateConnectionStringsSlot(
                        resourceGroupName,
                        webSiteName,
                        new ConnectionStringDictionary {
                        Properties = connectionStrings
                    },
                        slotName);
                }

                if (azureStorageSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateAzureStorageAccountsSlot(
                        resourceGroupName,
                        webSiteName,
                        azureStorageSettings,
                        slotName);
                }
            }
            else
            {
                if (appSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateApplicationSettings(
                        resourceGroupName,
                        webSiteName,
                        new StringDictionary {
                        Properties = appSettings
                    });
                }

                if (siteConfig != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateConfiguration(resourceGroupName, webSiteName, siteConfig.ConvertToSiteConfigResource());
                }

                if (connectionStrings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateConnectionStrings(
                        resourceGroupName,
                        webSiteName,
                        new ConnectionStringDictionary {
                        Properties = connectionStrings
                    });
                }

                if (azureStorageSettings != null)
                {
                    WrappedWebsitesClient.WebApps().UpdateAzureStorageAccounts(
                        resourceGroupName,
                        webSiteName,
                        azureStorageSettings);
                }
            }
        }