Esempio n. 1
0
 public SiteLimits2(SiteLimits siteLimits)
 {
     ConnectionTimeout = siteLimits.ConnectionTimeout;
     MaxBandwidth      = siteLimits.MaxBandwidth;
     MaxConnections    = siteLimits.MaxConnections;
     MaxUrlSegments    = siteLimits.MaxUrlSegments;
 }
 internal SiteConfigAutoGeneratedData(ResourceIdentifier id, string name, ResourceType type, string kind, int?numberOfWorkers, IList <string> defaultDocuments, string netFrameworkVersion, string phpVersion, string pythonVersion, string nodeVersion, string powerShellVersion, string linuxFxVersion, string windowsFxVersion, bool?requestTracingEnabled, DateTimeOffset?requestTracingExpirationTime, bool?remoteDebuggingEnabled, string remoteDebuggingVersion, bool?httpLoggingEnabled, bool?acrUseManagedIdentityCreds, string acrUserManagedIdentityID, int?logsDirectorySizeLimit, bool?detailedErrorLoggingEnabled, string publishingUsername, IList <NameValuePair> appSettings, IList <ConnStringInfo> connectionStrings, SiteMachineKey machineKey, IList <HandlerMapping> handlerMappings, string documentRoot, ScmType?scmType, bool?use32BitWorkerProcess, bool?webSocketsEnabled, bool?alwaysOn, string javaVersion, string javaContainer, string javaContainerVersion, string appCommandLine, ManagedPipelineMode?managedPipelineMode, IList <VirtualApplication> virtualApplications, SiteLoadBalancing?loadBalancing, Experiments experiments, SiteLimits limits, bool?autoHealEnabled, AutoHealRules autoHealRules, string tracingOptions, string vnetName, bool?vnetRouteAllEnabled, int?vnetPrivatePortsCount, CorsSettings cors, PushSettings push, ApiDefinitionInfo apiDefinition, ApiManagementConfig apiManagementConfig, string autoSwapSlotName, bool?localMySqlEnabled, int?managedServiceIdentityId, int?xManagedServiceIdentityId, string keyVaultReferenceIdentity, IList <IpSecurityRestriction> ipSecurityRestrictions, IList <IpSecurityRestriction> scmIpSecurityRestrictions, bool?scmIpSecurityRestrictionsUseMain, bool?http20Enabled, FtpsState?ftpsState, int?preWarmedInstanceCount, int?functionAppScaleLimit, string healthCheckPath, bool?functionsRuntimeScaleMonitoringEnabled, string websiteTimeZone, int?minimumElasticInstanceCount, IDictionary <string, AzureStorageInfoValue> azureStorageAccounts, string publicNetworkAccess) : base(id, name, type, kind)
 {
     NumberOfWorkers              = numberOfWorkers;
     DefaultDocuments             = defaultDocuments;
     NetFrameworkVersion          = netFrameworkVersion;
     PhpVersion                   = phpVersion;
     PythonVersion                = pythonVersion;
     NodeVersion                  = nodeVersion;
     PowerShellVersion            = powerShellVersion;
     LinuxFxVersion               = linuxFxVersion;
     WindowsFxVersion             = windowsFxVersion;
     RequestTracingEnabled        = requestTracingEnabled;
     RequestTracingExpirationTime = requestTracingExpirationTime;
     RemoteDebuggingEnabled       = remoteDebuggingEnabled;
     RemoteDebuggingVersion       = remoteDebuggingVersion;
     HttpLoggingEnabled           = httpLoggingEnabled;
     AcrUseManagedIdentityCreds   = acrUseManagedIdentityCreds;
     AcrUserManagedIdentityID     = acrUserManagedIdentityID;
     LogsDirectorySizeLimit       = logsDirectorySizeLimit;
     DetailedErrorLoggingEnabled  = detailedErrorLoggingEnabled;
     PublishingUsername           = publishingUsername;
     AppSettings                  = appSettings;
     ConnectionStrings            = connectionStrings;
     MachineKey                   = machineKey;
     HandlerMappings              = handlerMappings;
     DocumentRoot                 = documentRoot;
     ScmType = scmType;
     Use32BitWorkerProcess = use32BitWorkerProcess;
     WebSocketsEnabled     = webSocketsEnabled;
     AlwaysOn             = alwaysOn;
     JavaVersion          = javaVersion;
     JavaContainer        = javaContainer;
     JavaContainerVersion = javaContainerVersion;
     AppCommandLine       = appCommandLine;
     ManagedPipelineMode  = managedPipelineMode;
     VirtualApplications  = virtualApplications;
     LoadBalancing        = loadBalancing;
     Experiments          = experiments;
     Limits                = limits;
     AutoHealEnabled       = autoHealEnabled;
     AutoHealRules         = autoHealRules;
     TracingOptions        = tracingOptions;
     VnetName              = vnetName;
     VnetRouteAllEnabled   = vnetRouteAllEnabled;
     VnetPrivatePortsCount = vnetPrivatePortsCount;
     Cors                                   = cors;
     Push                                   = push;
     ApiDefinition                          = apiDefinition;
     ApiManagementConfig                    = apiManagementConfig;
     AutoSwapSlotName                       = autoSwapSlotName;
     LocalMySqlEnabled                      = localMySqlEnabled;
     ManagedServiceIdentityId               = managedServiceIdentityId;
     XManagedServiceIdentityId              = xManagedServiceIdentityId;
     KeyVaultReferenceIdentity              = keyVaultReferenceIdentity;
     IpSecurityRestrictions                 = ipSecurityRestrictions;
     ScmIpSecurityRestrictions              = scmIpSecurityRestrictions;
     ScmIpSecurityRestrictionsUseMain       = scmIpSecurityRestrictionsUseMain;
     Http20Enabled                          = http20Enabled;
     FtpsState                              = ftpsState;
     PreWarmedInstanceCount                 = preWarmedInstanceCount;
     FunctionAppScaleLimit                  = functionAppScaleLimit;
     HealthCheckPath                        = healthCheckPath;
     FunctionsRuntimeScaleMonitoringEnabled = functionsRuntimeScaleMonitoringEnabled;
     WebsiteTimeZone                        = websiteTimeZone;
     MinimumElasticInstanceCount            = minimumElasticInstanceCount;
     AzureStorageAccounts                   = azureStorageAccounts;
     PublicNetworkAccess                    = publicNetworkAccess;
 }
        public void GetAndSetSiteLimits()
        {
            var handler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var webSitesClient  = ResourceGroupHelper.GetWebSitesClient(handler);
                var resourcesClient = ResourceGroupHelper.GetResourcesClient(handler);

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

                var    locationName = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites");
                string siteName     = TestUtilities.GenerateName("csmws");

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

                webSitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, new WebHostingPlanCreateOrUpdateParameters
                {
                    WebHostingPlan = new WebHostingPlan
                    {
                        Name       = whpName,
                        Location   = locationName,
                        Properties = new WebHostingPlanProperties
                        {
                            NumberOfWorkers = 1,
                            WorkerSize      = WorkerSizeOptions.Small
                        }
                    }
                });

                var createResponse = webSitesClient.WebSites.CreateOrUpdate(resourceGroupName, siteName, null, new WebSiteCreateOrUpdateParameters()
                {
                    WebSite = new WebSiteBase()
                    {
                        Name       = siteName,
                        Location   = locationName,
                        Properties = new WebSiteBaseProperties()
                        {
                            ServerFarm = whpName
                        }
                    }
                });

                #region Get/Set Site limits

                var expectedSitelimits = new SiteLimits()
                {
                    MaxDiskSizeInMb  = 512,
                    MaxMemoryInMb    = 1024,
                    MaxPercentageCpu = 70.5
                };
                var parameters = new WebSiteUpdateConfigurationParameters()
                {
                    Location   = locationName,
                    Properties = new WebSiteUpdateConfigurationDetails()
                    {
                        Limits = expectedSitelimits
                    }
                };


                var siteUpdateConfigResponse = webSitesClient.WebSites.UpdateConfiguration(
                    resourceGroupName,
                    siteName,
                    null,
                    parameters);

                Assert.Equal(HttpStatusCode.OK, siteUpdateConfigResponse.StatusCode);

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

                Assert.NotNull(siteGetConfigResponse);
                Assert.NotNull(siteGetConfigResponse.Resource);
                Assert.NotNull(siteGetConfigResponse.Resource.Properties);
                var limits = siteGetConfigResponse.Resource.Properties.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.WebSites.Delete(resourceGroupName, siteName, null, new WebSiteDeleteParameters()
                {
                    DeleteAllSlots = true,
                    DeleteMetrics  = true
                });

                webSitesClient.WebHostingPlans.Delete(resourceGroupName, whpName);
            }
        }
Esempio n. 4
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);
            }
        }