Ejemplo n.º 1
0
        public void GetAndSetNonSensitiveSiteConfigs()
        {
            RunWebsiteTestScenario(
                (siteName, resourceGroupName, whpName, locationName, webSitesClient, resourcesClient) =>
            {
                #region Get/Set PythonVersion

                var configurationResponse = webSitesClient.WebApps.GetConfiguration(resourceGroupName,
                                                                                    siteName);

                Assert.NotNull(configurationResponse);
                Assert.True(string.IsNullOrEmpty(configurationResponse.PythonVersion));

                var configurationParameters = new SiteConfigResource
                {
                    PythonVersion = "3.4"
                };

                var operationResponse = webSitesClient.WebApps.UpdateConfiguration(resourceGroupName,
                                                                                   siteName, configurationParameters);

                configurationResponse = webSitesClient.WebApps.GetConfiguration(resourceGroupName, siteName);

                Assert.NotNull(configurationResponse);
                Assert.Equal(configurationResponse.PythonVersion, configurationParameters.PythonVersion);

                #endregion Get/Set PythonVersion
            });
        }
        private bool IsVirtualDirectorySetup(SiteConfigResource siteConfig)
        {
            var isSetupAsAppliction = siteConfig.VirtualApplications.Any(s => s.PhysicalPath.StartsWith(wellKnownPhysicalPath));
            var isSetupAsDirectory  = siteConfig.VirtualApplications.Any(s => s.VirtualDirectories.Any(d => d.PhysicalPath.StartsWith(wellKnownPhysicalPath)));

            return(isSetupAsAppliction || isSetupAsDirectory);
        }
 public static SiteConfigResource UpdateSiteConfigSlot(this IWebAppsOperations webApp,
                                                       string resourceGroupName,
                                                       string name,
                                                       SiteConfigResource siteConfig,
                                                       string slot)
 {
     return(webApp.UpdateConfigurationSlot(resourceGroupName, name, siteConfig, slot));
 }
Ejemplo n.º 4
0
 internal static SiteConfig ConvertToSiteConfig(this SiteConfigResource config)
 {
     return(new SiteConfig
     {
         AlwaysOn = config.AlwaysOn,
         ApiDefinition = config.ApiDefinition,
         AppCommandLine = config.AppCommandLine,
         AppSettings = config.AppSettings,
         AutoHealEnabled = config.AutoHealEnabled,
         AutoHealRules = config.AutoHealRules,
         AutoSwapSlotName = config.AutoSwapSlotName,
         ConnectionStrings = config.ConnectionStrings,
         Cors = config.Cors,
         DefaultDocuments = config.DefaultDocuments,
         DetailedErrorLoggingEnabled = config.DetailedErrorLoggingEnabled,
         DocumentRoot = config.DocumentRoot,
         Experiments = config.Experiments,
         HandlerMappings = config.HandlerMappings,
         HttpLoggingEnabled = config.HttpLoggingEnabled,
         IpSecurityRestrictions = config.IpSecurityRestrictions,
         JavaContainer = config.JavaContainer,
         JavaContainerVersion = config.JavaContainerVersion,
         JavaVersion = config.JavaVersion,
         Limits = config.Limits,
         LinuxFxVersion = config.LinuxFxVersion,
         LoadBalancing = config.LoadBalancing,
         LocalMySqlEnabled = config.LocalMySqlEnabled,
         LogsDirectorySizeLimit = config.LogsDirectorySizeLimit,
         ManagedPipelineMode = config.ManagedPipelineMode,
         NetFrameworkVersion = config.NetFrameworkVersion,
         NodeVersion = config.NodeVersion,
         NumberOfWorkers = config.NumberOfWorkers,
         PhpVersion = config.PhpVersion,
         PublishingUsername = config.PublishingUsername,
         Push = config.Push,
         PythonVersion = config.PythonVersion,
         RemoteDebuggingEnabled = config.RemoteDebuggingEnabled,
         RemoteDebuggingVersion = config.RemoteDebuggingVersion,
         RequestTracingEnabled = config.RequestTracingEnabled,
         RequestTracingExpirationTime = config.RequestTracingExpirationTime,
         ScmType = config.ScmType,
         TracingOptions = config.TracingOptions,
         Use32BitWorkerProcess = config.Use32BitWorkerProcess,
         VirtualApplications = config.VirtualApplications,
         VnetName = config.VnetName,
         WebSocketsEnabled = config.WebSocketsEnabled,
         WindowsFxVersion = config.WindowsFxVersion,
         ManagedServiceIdentityId = config.ManagedServiceIdentityId,
         MinTlsVersion = config.MinTlsVersion,
         FtpsState = config.FtpsState,
         ScmIpSecurityRestrictions = config.ScmIpSecurityRestrictions,
         ScmIpSecurityRestrictionsUseMain = config.ScmIpSecurityRestrictionsUseMain,
         Http20Enabled = config.Http20Enabled,
         VnetRouteAllEnabled = config.VnetRouteAllEnabled,
         HealthCheckPath = config.HealthCheckPath
     });
 }
 public static async Task UpdateConfigurationAsync(this IWebAppsOperations operations, TargetSite targetSite,
                                                   SiteConfigResource config, CancellationToken cancellationToken = default)
 {
     if (targetSite.HasSlot)
     {
         await operations.UpdateConfigurationSlotWithHttpMessagesAsync(targetSite.ResourceGroupName,
                                                                       targetSite.Site, config, targetSite.Slot, cancellationToken : cancellationToken);
     }
     else
     {
         await operations.UpdateConfigurationWithHttpMessagesAsync(targetSite.ResourceGroupName,
                                                                   targetSite.ScmSiteAndSlot, config, cancellationToken : cancellationToken);
     }
 }
        public static Task <SiteConfigResource> UpdateConfigurationAsync(this IWebAppsOperations operations, Site site, SiteConfigResource siteConfig, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (site.IsSlot())
            {
                var(siteName, slotName) = site.SplitName();

                return(operations.UpdateConfigurationSlotAsync(site.ResourceGroup, siteName, siteConfig, slotName, cancellationToken));
            }

            return(operations.UpdateConfigurationAsync(site.ResourceGroup, site.Name, siteConfig, cancellationToken));
        }
Ejemplo n.º 7
0
        public void GetAndSetSiteLimits()
        {
            using (var context = MockContext.Start(this.GetType().FullName))
            {
                var webSitesClient  = this.GetWebSiteManagementClient(context);
                var resourcesClient = this.GetResourceManagementClient(context);

                var whpName           = TestUtilities.GenerateName("cswhp");
                var resourceGroupName = TestUtilities.GenerateName("csmrg");

                var serverfarmId = ResourceGroupHelper.GetServerFarmId(webSitesClient.SubscriptionId,
                                                                       resourceGroupName, whpName);
                var locationName = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites");
                var siteName     = TestUtilities.GenerateName("csmws");

                resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                              new ResourceGroup
                {
                    Location = locationName
                });

                webSitesClient.AppServicePlans.CreateOrUpdate(resourceGroupName, whpName, new AppServicePlan()
                {
                    Location = locationName,
                    Sku      = new SkuDescription
                    {
                        Name     = "D1",
                        Tier     = "Shared",
                        Capacity = 1
                    }
                });

                var createResponse = webSitesClient.WebApps.CreateOrUpdate(resourceGroupName, siteName, new Site
                {
                    Location     = locationName,
                    ServerFarmId = serverfarmId
                });

                #region Get/Set Site limits

                var expectedSitelimits = new SiteLimits()
                {
                    MaxDiskSizeInMb  = 512,
                    MaxMemoryInMb    = 1024,
                    MaxPercentageCpu = 70.5
                };
                var siteConfig = new SiteConfigResource
                {
                    Limits = expectedSitelimits
                };

                webSitesClient.WebApps.UpdateConfiguration(
                    resourceGroupName,
                    siteName,
                    siteConfig);

                var siteGetConfigResponse = webSitesClient.WebApps.GetConfiguration(resourceGroupName, siteName);

                Assert.NotNull(siteGetConfigResponse);
                var limits = siteGetConfigResponse.Limits;
                Assert.NotNull(limits);
                Assert.Equal(expectedSitelimits.MaxDiskSizeInMb, limits.MaxDiskSizeInMb);
                Assert.Equal(expectedSitelimits.MaxMemoryInMb, limits.MaxMemoryInMb);
                Assert.Equal(expectedSitelimits.MaxPercentageCpu, limits.MaxPercentageCpu);

                #endregion Get/Set Site limits

                webSitesClient.WebApps.Delete(resourceGroupName, siteName, deleteMetrics: true);
                webSitesClient.AppServicePlans.Delete(resourceGroupName, whpName);
            }
        }
Ejemplo n.º 8
0
 public static SiteConfigResource UpdateSiteConfigurationOrSlot(this IWebAppsOperations sites, string resourceGroupName, string webAppName, string siteSlotName, SiteConfigResource config)
 {
     if (string.IsNullOrEmpty(siteSlotName))
     {
         return(sites.UpdateConfiguration(resourceGroupName, webAppName, config));
     }
     else
     {
         return(sites.UpdateConfigurationSlot(resourceGroupName, webAppName, config, siteSlotName));
     }
 }