///GENMHASH:3E41C75F291566718F049BE8298BE8DC:A12B779940ABC1017C310E5DAEB47E21
 public static PricingTier FromSkuDescription(SkuDescription skuDescription)
 {
     return(new PricingTier()
     {
         SkuDescription = skuDescription
     });
 }
 internal AppServicePlanData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string kind, SkuDescription sku, ExtendedLocation extendedLocation, string workerTierName, StatusOptions?status, string subscription, HostingEnvironmentProfile hostingEnvironmentProfile, int?maximumNumberOfWorkers, string geoRegion, bool?perSiteScaling, bool?elasticScaleEnabled, int?maximumElasticWorkerCount, int?numberOfSites, bool?isSpot, DateTimeOffset?spotExpirationTime, DateTimeOffset?freeOfferExpirationTime, string resourceGroup, bool?reserved, bool?isXenon, bool?hyperV, int?targetWorkerCount, int?targetWorkerSizeId, ProvisioningState?provisioningState, KubeEnvironmentProfile kubeEnvironmentProfile, bool?zoneRedundant) : base(id, name, type, systemData, tags, location, kind)
 {
     Sku = sku;
     ExtendedLocation          = extendedLocation;
     WorkerTierName            = workerTierName;
     Status                    = status;
     Subscription              = subscription;
     HostingEnvironmentProfile = hostingEnvironmentProfile;
     MaximumNumberOfWorkers    = maximumNumberOfWorkers;
     GeoRegion                 = geoRegion;
     PerSiteScaling            = perSiteScaling;
     ElasticScaleEnabled       = elasticScaleEnabled;
     MaximumElasticWorkerCount = maximumElasticWorkerCount;
     NumberOfSites             = numberOfSites;
     IsSpot                    = isSpot;
     SpotExpirationTime        = spotExpirationTime;
     FreeOfferExpirationTime   = freeOfferExpirationTime;
     ResourceGroup             = resourceGroup;
     Reserved                  = reserved;
     IsXenon                   = isXenon;
     HyperV                    = hyperV;
     TargetWorkerCount         = targetWorkerCount;
     TargetWorkerSizeId        = targetWorkerSizeId;
     ProvisioningState         = provisioningState;
     KubeEnvironmentProfile    = kubeEnvironmentProfile;
     ZoneRedundant             = zoneRedundant;
 }
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrWhiteSpace(Tier))
            {
                Tier = "Free";
            }

            if (string.IsNullOrWhiteSpace(WorkerSize))
            {
                WorkerSize = "Small";
            }

            var aseResourceGroupName = AseResourceGroupName;

            if (!string.IsNullOrEmpty(AseName)
                && string.IsNullOrEmpty(aseResourceGroupName))
            {
                aseResourceGroupName = ResourceGroupName;
            }

            var capacity = NumberofWorkers < 1 ? 1 : NumberofWorkers;
            var skuName = CmdletHelpers.GetSkuName(Tier, WorkerSize);

            var sku = new SkuDescription
            {
                Tier = Tier,
                Name = skuName,
                Capacity = capacity
            };

            WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, null, sku, AseName, aseResourceGroupName), true);
        }
示例#4
0
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrWhiteSpace(Tier))
            {
                Tier = "Free";
            }

            if (string.IsNullOrWhiteSpace(WorkerSize))
            {
                WorkerSize = "Small";
            }

            var aseResourceGroupName = AseResourceGroupName;

            if (!string.IsNullOrEmpty(AseName) &&
                string.IsNullOrEmpty(aseResourceGroupName))
            {
                aseResourceGroupName = ResourceGroupName;
            }

            var capacity = NumberofWorkers < 1 ? 1 : NumberofWorkers;
            var skuName  = CmdletHelpers.GetSkuName(Tier, WorkerSize);

            var sku = new SkuDescription
            {
                Tier     = Tier,
                Name     = skuName,
                Capacity = capacity
            };

            WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, null, sku, AseName, aseResourceGroupName, PerSiteScaling), true);
        }
示例#5
0
        private void ValidateSku(SkuDescription sku)
        {
            if (sku == null)
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU' cannot be null");
            }

            const string skuNamePattern = "^[fdbspFDBSP][1-9]$";

            if (!Regex.IsMatch(sku.Name, skuNamePattern))
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU.Name' must conform to format first letter of sku name and numerical value of worker size. Worker Size [Small = 1, Medium = 2, Large = 3, ExtraLarge = 4] For instance, F1 means free small workers, P3 means premium large workers. ");
            }

            const string tierPattern = "^(Free|Shared|Basic|Standard|Premium)$";

            if (!Regex.IsMatch(sku.Tier, tierPattern, RegexOptions.IgnoreCase))
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU.Tier' must be one of Free|Shared|Basic|Standard|Premium");
            }

            var firstLetter = string.Equals("Shared", sku.Tier, StringComparison.OrdinalIgnoreCase) ? 'D' : sku.Tier[0];

            if (char.ToUpperInvariant(firstLetter) != char.ToUpperInvariant(sku.Name[0]))
            {
                throw new ValidationMetadataException(string.Format("Arguments 'ServerFarm.SKU.Name' and 'ServerFarm.SKU.Tier' must point to the same tier. [F = Free, D = Shared, B = Basic, S = Standard, P = Premium]. Current values: SKU.Name = {0}, SKU.Tier = {1}", sku.Name, sku.Tier));
            }
        }
        private void ValidateSku(SkuDescription sku)
        {
            if (sku == null)
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU' cannot be null");
            }

            const string skuNamePattern = "^[fdbspFDBSP][1-9]$";
            if (!Regex.IsMatch(sku.Name, skuNamePattern))
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU.Name' must conform to format first letter of sku name and numerical value of worker size. Worker Size [Small = 1, Medium = 2, Large = 3, ExtraLarge = 4] For instance, F1 means free small workers, P3 means premium large workers. ");
            }

            const string tierPattern = "^(Free|Shared|Basic|Standard|Premium)$";
            if (!Regex.IsMatch(sku.Tier, tierPattern, RegexOptions.IgnoreCase))
            {
                throw new ValidationMetadataException("Argument 'ServerFarm.SKU.Tier' must be one of Free|Shared|Basic|Standard|Premium");
            }

            var firstLetter = string.Equals("Shared", sku.Tier, StringComparison.OrdinalIgnoreCase) ? 'D' : sku.Tier[0];
            if (char.ToUpperInvariant(firstLetter) != char.ToUpperInvariant(sku.Name[0]))
            {
                throw new ValidationMetadataException(string.Format("Arguments 'ServerFarm.SKU.Name' and 'ServerFarm.SKU.Tier' must point to the same tier. [F = Free, D = Shared, B = Basic, S = Standard, P = Premium]. Current values: SKU.Name = {0}, SKU.Tier = {1}", sku.Name, sku.Tier));
            }
        }
示例#7
0
 internal WorkerPoolResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string kind, SkuDescription sku, int?workerSizeId, ComputeModeOptions?computeMode, string workerSize, int?workerCount, IReadOnlyList <string> instanceNames) : base(id, name, resourceType, systemData, kind)
 {
     Sku           = sku;
     WorkerSizeId  = workerSizeId;
     ComputeMode   = computeMode;
     WorkerSize    = workerSize;
     WorkerCount   = workerCount;
     InstanceNames = instanceNames;
 }
 /// <summary>
 /// Creates a custom value for PricingTier.
 /// </summary>
 /// <param name="tier">the tier name</param>
 /// <param name="size">the size of the plan</param>
 public PricingTier(string tier, string size)
 {
     this.SkuDescription = new SkuDescription
     {
         Name = size,
         Tier = tier,
         Size = size
     };
 }
        public override void ExecuteCmdlet()
        {
            if (HyperV.IsPresent &&
                (Tier != "PremiumContainer" && Tier != "PremiumV3"))
            {
                throw new Exception("HyperV switch is only allowed for PremiumContainer or PremiumV3 tiers");
            }
            if (!HyperV.IsPresent && Tier == "PremiumContainer")
            {
                throw new Exception("PremiumContainer tier is only allowed if HyperV switch is present");
            }

            if (string.IsNullOrWhiteSpace(Tier))
            {
                Tier = "Free";
            }

            if (string.IsNullOrWhiteSpace(WorkerSize))
            {
                WorkerSize = "Small";
            }

            var aseResourceGroupName = AseResourceGroupName;

            if (!string.IsNullOrEmpty(AseName) &&
                string.IsNullOrEmpty(aseResourceGroupName))
            {
                aseResourceGroupName = ResourceGroupName;
            }

            var capacity = NumberofWorkers < 1 ? 1 : NumberofWorkers;
            var skuName  = CmdletHelpers.GetSkuName(Tier, WorkerSize);

            var sku = new SkuDescription
            {
                Tier     = Tier,
                Name     = skuName,
                Capacity = capacity
            };

            var appServicePlan = new AppServicePlan
            {
                Location       = Location,
                Sku            = sku,
                PerSiteScaling = PerSiteScaling,
                IsXenon        = HyperV.IsPresent,
                Tags           = (IDictionary <string, string>)CmdletHelpers.ConvertToStringDictionary(Tag),
                Reserved       = Linux.IsPresent
            };

            AppServicePlan   retPlan = WebsitesClient.CreateOrUpdateAppServicePlan(ResourceGroupName, Name, appServicePlan, AseName, aseResourceGroupName);
            PSAppServicePlan psPlan  = new PSAppServicePlan(retPlan);

            WriteObject(psPlan, true);
        }
示例#10
0
        private bool IsConsumptionAppServicePlan(PricingTier pricingTier)
        {
            if (pricingTier == null || pricingTier.SkuDescription == null)
            {
                return(true);
            }

            SkuDescription description = pricingTier.SkuDescription;

            return(description.Tier.Equals(SkuName.Dynamic.Value, StringComparison.OrdinalIgnoreCase) || description.Tier.Equals(SkuName.ElasticPremium.Value, StringComparison.OrdinalIgnoreCase));
        }
示例#11
0
        private bool IsConsumptionAppServicePlan(PricingTier pricingTier)
        {
            if (pricingTier == null || pricingTier.SkuDescription == null)
            {
                return(true);
            }

            SkuDescription description = pricingTier.SkuDescription;

            return(description.Tier.Equals("Dynamic", StringComparison.OrdinalIgnoreCase));
        }
示例#12
0
        private bool IsConsumptionAppServicePlan(PricingTier pricingTier)
        {
            if (pricingTier == null || pricingTier.SkuDescription == null)
            {
                return(true);
            }

            SkuDescription description = pricingTier.SkuDescription;

            return(!(description.Tier.Equals("Basic", StringComparison.OrdinalIgnoreCase) ||
                     description.Tier.Equals("Standard", StringComparison.OrdinalIgnoreCase) ||
                     description.Tier.Equals("Premium", StringComparison.OrdinalIgnoreCase)));
        }
        private FunctionAppImpl AutoSetAlwaysOn(PricingTier pricingTier)
        {
            SkuDescription description = pricingTier.SkuDescription;

            if (description.Tier.Equals("Basic", StringComparison.OrdinalIgnoreCase) ||
                description.Tier.Equals("Standard", StringComparison.OrdinalIgnoreCase) ||
                description.Tier.Equals("Premium", StringComparison.OrdinalIgnoreCase))
            {
                return(WithWebAppAlwaysOn(true));
            }
            else
            {
                return(WithWebAppAlwaysOn(false));
            }
        }
 internal StaticSiteARMResourceData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string kind, SkuDescription sku, ManagedServiceIdentity identity, string defaultHostname, string repositoryUrl, string branch, IReadOnlyList <string> customDomains, string repositoryToken, StaticSiteBuildProperties buildProperties, IReadOnlyList <ResponseMessageEnvelopeRemotePrivateEndpointConnection> privateEndpointConnections, StagingEnvironmentPolicy?stagingEnvironmentPolicy, bool?allowConfigFileUpdates, StaticSiteTemplateOptions templateProperties, string contentDistributionEndpoint, string keyVaultReferenceIdentity, IReadOnlyList <Models.StaticSiteUserProvidedFunctionApp> userProvidedFunctionApps, string provider) : base(id, name, type, systemData, tags, location, kind)
 {
     Sku                         = sku;
     Identity                    = identity;
     DefaultHostname             = defaultHostname;
     RepositoryUrl               = repositoryUrl;
     Branch                      = branch;
     CustomDomains               = customDomains;
     RepositoryToken             = repositoryToken;
     BuildProperties             = buildProperties;
     PrivateEndpointConnections  = privateEndpointConnections;
     StagingEnvironmentPolicy    = stagingEnvironmentPolicy;
     AllowConfigFileUpdates      = allowConfigFileUpdates;
     TemplateProperties          = templateProperties;
     ContentDistributionEndpoint = contentDistributionEndpoint;
     KeyVaultReferenceIdentity   = keyVaultReferenceIdentity;
     UserProvidedFunctionApps    = userProvidedFunctionApps;
     Provider                    = provider;
 }
        protected override void ProcessRecord()
        {
            if (string.IsNullOrWhiteSpace(Tier))
            {
                Tier = "Free";
            }

            if (string.IsNullOrWhiteSpace(WorkerSize))
            {
                WorkerSize = "Small";
            }

            var capacity = NumberofWorkers < 1 ? 1 : NumberofWorkers;
            var skuName = CmdletHelpers.GetSkuName(Tier, WorkerSize);

            var sku = new SkuDescription
            {
                Tier = Tier,
                Name = skuName,
                Capacity = capacity
            };

            WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, null, sku), true);
        }
示例#16
0
        protected override void ProcessRecord()
        {
            if (string.IsNullOrWhiteSpace(Tier))
            {
                Tier = "Free";
            }

            if (string.IsNullOrWhiteSpace(WorkerSize))
            {
                WorkerSize = "Small";
            }

            var capacity = NumberofWorkers < 1 ? 1 : NumberofWorkers;
            var skuName  = CmdletHelpers.GetSkuName(Tier, WorkerSize);

            var sku = new SkuDescription
            {
                Tier     = Tier,
                Name     = skuName,
                Capacity = capacity
            };

            WriteObject(WebsitesClient.CreateAppServicePlan(ResourceGroupName, Name, Location, null, sku), true);
        }
 public ServerFarmWithRichSku CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku)
 {
     var serverFarm = new ServerFarmWithRichSku
     {
         Location = location,
         ServerFarmWithRichSkuName = appServicePlanName,
         Sku = sku,
         AdminSiteName = adminSiteName
     };
     
     return WrappedWebsitesClient.ServerFarms.CreateOrUpdateServerFarm(resourceGroupName, appServicePlanName, serverFarm);
 }
        internal static StaticSiteARMResourceData DeserializeStaticSiteARMResourceData(JsonElement element)
        {
            Optional <SkuDescription>         sku      = default;
            Optional <ManagedServiceIdentity> identity = default;
            Optional <string>            kind          = default;
            IDictionary <string, string> tags          = default;
            Location           location        = default;
            ResourceIdentifier id              = default;
            string             name            = default;
            ResourceType       type            = default;
            Optional <string>  defaultHostname = default;
            Optional <string>  repositoryUrl   = default;
            Optional <string>  branch          = default;
            Optional <IReadOnlyList <string> > customDomains = default;
            Optional <string> repositoryToken = default;
            Optional <StaticSiteBuildProperties> buildProperties = default;
            Optional <IReadOnlyList <ResponseMessageEnvelopeRemotePrivateEndpointConnection> > privateEndpointConnections = default;
            Optional <StagingEnvironmentPolicy> stagingEnvironmentPolicy = default;
            Optional <bool> allowConfigFileUpdates = default;
            Optional <StaticSiteTemplateOptions> templateProperties = default;
            Optional <string> contentDistributionEndpoint           = default;
            Optional <string> keyVaultReferenceIdentity             = default;
            Optional <IReadOnlyList <Models.StaticSiteUserProvidedFunctionApp> > userProvidedFunctionApps = default;
            Optional <string> provider = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = SkuDescription.DeserializeSkuDescription(property.Value);
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = ManagedServiceIdentity.DeserializeManagedServiceIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("defaultHostname"))
                        {
                            defaultHostname = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("repositoryUrl"))
                        {
                            repositoryUrl = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("branch"))
                        {
                            branch = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("customDomains"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            customDomains = array;
                            continue;
                        }
                        if (property0.NameEquals("repositoryToken"))
                        {
                            repositoryToken = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("buildProperties"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            buildProperties = StaticSiteBuildProperties.DeserializeStaticSiteBuildProperties(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointConnections"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResponseMessageEnvelopeRemotePrivateEndpointConnection> array = new List <ResponseMessageEnvelopeRemotePrivateEndpointConnection>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResponseMessageEnvelopeRemotePrivateEndpointConnection.DeserializeResponseMessageEnvelopeRemotePrivateEndpointConnection(item));
                            }
                            privateEndpointConnections = array;
                            continue;
                        }
                        if (property0.NameEquals("stagingEnvironmentPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            stagingEnvironmentPolicy = property0.Value.GetString().ToStagingEnvironmentPolicy();
                            continue;
                        }
                        if (property0.NameEquals("allowConfigFileUpdates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            allowConfigFileUpdates = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("templateProperties"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            templateProperties = StaticSiteTemplateOptions.DeserializeStaticSiteTemplateOptions(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("contentDistributionEndpoint"))
                        {
                            contentDistributionEndpoint = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("keyVaultReferenceIdentity"))
                        {
                            keyVaultReferenceIdentity = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("userProvidedFunctionApps"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <Models.StaticSiteUserProvidedFunctionApp> array = new List <Models.StaticSiteUserProvidedFunctionApp>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(Models.StaticSiteUserProvidedFunctionApp.DeserializeStaticSiteUserProvidedFunctionApp(item));
                            }
                            userProvidedFunctionApps = array;
                            continue;
                        }
                        if (property0.NameEquals("provider"))
                        {
                            provider = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new StaticSiteARMResourceData(id, name, type, tags, location, kind.Value, sku.Value, identity.Value, defaultHostname.Value, repositoryUrl.Value, branch.Value, Optional.ToList(customDomains), repositoryToken.Value, buildProperties.Value, Optional.ToList(privateEndpointConnections), Optional.ToNullable(stagingEnvironmentPolicy), Optional.ToNullable(allowConfigFileUpdates), templateProperties.Value, contentDistributionEndpoint.Value, keyVaultReferenceIdentity.Value, Optional.ToList(userProvidedFunctionApps), provider.Value));
        }
        internal static AppServicePlanData DeserializeAppServicePlanData(JsonElement element)
        {
            Optional <SkuDescription>    sku = default;
            Optional <ExtendedLocation>  extendedLocation                  = default;
            Optional <string>            kind                              = default;
            IDictionary <string, string> tags                              = default;
            AzureLocation                        location                  = default;
            ResourceIdentifier                   id                        = default;
            string                               name                      = default;
            ResourceType                         type                      = default;
            SystemData                           systemData                = default;
            Optional <string>                    workerTierName            = default;
            Optional <StatusOptions>             status                    = default;
            Optional <string>                    subscription              = default;
            Optional <HostingEnvironmentProfile> hostingEnvironmentProfile = default;
            Optional <int>                       maximumNumberOfWorkers    = default;
            Optional <string>                    geoRegion                 = default;
            Optional <bool>                      perSiteScaling            = default;
            Optional <bool>                      elasticScaleEnabled       = default;
            Optional <int>                       maximumElasticWorkerCount = default;
            Optional <int>                       numberOfSites             = default;
            Optional <bool>                      isSpot                    = default;
            Optional <DateTimeOffset?>           spotExpirationTime        = default;
            Optional <DateTimeOffset?>           freeOfferExpirationTime   = default;
            Optional <string>                    resourceGroup             = default;
            Optional <bool>                      reserved                  = default;
            Optional <bool>                      isXenon                   = default;
            Optional <bool>                      hyperV                    = default;
            Optional <int>                       targetWorkerCount         = default;
            Optional <int>                       targetWorkerSizeId        = default;
            Optional <ProvisioningState>         provisioningState         = default;
            Optional <KubeEnvironmentProfile>    kubeEnvironmentProfile    = default;
            Optional <bool>                      zoneRedundant             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = SkuDescription.DeserializeSkuDescription(property.Value);
                    continue;
                }
                if (property.NameEquals("extendedLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("workerTierName"))
                        {
                            workerTierName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("status"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            status = property0.Value.GetString().ToStatusOptions();
                            continue;
                        }
                        if (property0.NameEquals("subscription"))
                        {
                            subscription = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("hostingEnvironmentProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                hostingEnvironmentProfile = null;
                                continue;
                            }
                            hostingEnvironmentProfile = HostingEnvironmentProfile.DeserializeHostingEnvironmentProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("maximumNumberOfWorkers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maximumNumberOfWorkers = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("geoRegion"))
                        {
                            geoRegion = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("perSiteScaling"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            perSiteScaling = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("elasticScaleEnabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            elasticScaleEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("maximumElasticWorkerCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maximumElasticWorkerCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("numberOfSites"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            numberOfSites = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("isSpot"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isSpot = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("spotExpirationTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                spotExpirationTime = null;
                                continue;
                            }
                            spotExpirationTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("freeOfferExpirationTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                freeOfferExpirationTime = null;
                                continue;
                            }
                            freeOfferExpirationTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("resourceGroup"))
                        {
                            resourceGroup = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("reserved"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            reserved = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("isXenon"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            isXenon = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("hyperV"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hyperV = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("targetWorkerCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            targetWorkerCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("targetWorkerSizeId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            targetWorkerSizeId = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = property0.Value.GetString().ToProvisioningState();
                            continue;
                        }
                        if (property0.NameEquals("kubeEnvironmentProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                kubeEnvironmentProfile = null;
                                continue;
                            }
                            kubeEnvironmentProfile = KubeEnvironmentProfile.DeserializeKubeEnvironmentProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("zoneRedundant"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            zoneRedundant = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new AppServicePlanData(id, name, type, systemData, tags, location, kind.Value, sku.Value, extendedLocation.Value, workerTierName.Value, Optional.ToNullable(status), subscription.Value, hostingEnvironmentProfile.Value, Optional.ToNullable(maximumNumberOfWorkers), geoRegion.Value, Optional.ToNullable(perSiteScaling), Optional.ToNullable(elasticScaleEnabled), Optional.ToNullable(maximumElasticWorkerCount), Optional.ToNullable(numberOfSites), Optional.ToNullable(isSpot), Optional.ToNullable(spotExpirationTime), Optional.ToNullable(freeOfferExpirationTime), resourceGroup.Value, Optional.ToNullable(reserved), Optional.ToNullable(isXenon), Optional.ToNullable(hyperV), Optional.ToNullable(targetWorkerCount), Optional.ToNullable(targetWorkerSizeId), Optional.ToNullable(provisioningState), kubeEnvironmentProfile.Value, Optional.ToNullable(zoneRedundant)));
        }
        internal static WorkerPoolResourceData DeserializeWorkerPoolResourceData(JsonElement element)
        {
            Optional <SkuDescription> sku                    = default;
            Optional <string>         kind                   = default;
            ResourceIdentifier        id                     = default;
            string         name                              = default;
            ResourceType   type                              = default;
            Optional <int> workerSizeId                      = default;
            Optional <ComputeModeOptions> computeMode        = default;
            Optional <string>             workerSize         = default;
            Optional <int> workerCount                       = default;
            Optional <IReadOnlyList <string> > instanceNames = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = SkuDescription.DeserializeSkuDescription(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("workerSizeId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            workerSizeId = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("computeMode"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            computeMode = property0.Value.GetString().ToComputeModeOptions();
                            continue;
                        }
                        if (property0.NameEquals("workerSize"))
                        {
                            workerSize = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("workerCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            workerCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("instanceNames"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            instanceNames = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new WorkerPoolResourceData(id, name, type, kind.Value, sku.Value, Optional.ToNullable(workerSizeId), Optional.ToNullable(computeMode), workerSize.Value, Optional.ToNullable(workerCount), Optional.ToList(instanceNames)));
        }
示例#21
0
        public ServerFarmWithRichSku CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku, string aseName = null, string aseResourceGroupName = null)
        {
            var serverFarm = new ServerFarmWithRichSku
            {
                Location = location,
                ServerFarmWithRichSkuName = appServicePlanName,
                Sku           = sku,
                AdminSiteName = adminSiteName
            };

            if (!string.IsNullOrEmpty(aseName) &&
                !string.IsNullOrEmpty(aseResourceGroupName))
            {
                serverFarm.HostingEnvironmentProfile = new HostingEnvironmentProfile
                {
                    Id   = CmdletHelpers.GetApplicationServiceEnvironmentResourceId(WrappedWebsitesClient.SubscriptionId, aseResourceGroupName, aseName),
                    Type = CmdletHelpers.ApplicationServiceEnvironmentResourcesName,
                    Name = aseName
                };
            }

            return(WrappedWebsitesClient.ServerFarms.CreateOrUpdateServerFarm(resourceGroupName, appServicePlanName, serverFarm));
        }
        public ServerFarmWithRichSku CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku, string aseName = null, string aseResourceGroupName = null, bool?perSiteScaling = false)
        {
            var serverFarm = new ServerFarmWithRichSku
            {
                Location = location,
#if !NETSTANDARD
                ServerFarmWithRichSkuName = appServicePlanName,
#else
                Name = appServicePlanName,
#endif
                Sku            = sku,
                AdminSiteName  = adminSiteName,
                PerSiteScaling = perSiteScaling
            };

            if (!string.IsNullOrEmpty(aseName) &&
                !string.IsNullOrEmpty(aseResourceGroupName))
            {
                serverFarm.HostingEnvironmentProfile = new HostingEnvironmentProfile(
                    id: CmdletHelpers.GetApplicationServiceEnvironmentResourceId(WrappedWebsitesClient.SubscriptionId, aseResourceGroupName, aseName),
                    name: aseName,
                    type: CmdletHelpers.ApplicationServiceEnvironmentResourcesName);
            }

            return(WrappedWebsitesClient.AppServicePlans().CreateOrUpdateServerFarm(resourceGroupName, appServicePlanName, serverFarm));
        }
        public ServerFarmWithRichSku CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku, string aseName = null, string aseResourceGroupName = null)
        {
            var serverFarm = new ServerFarmWithRichSku
            {
                Location = location,
                ServerFarmWithRichSkuName = appServicePlanName,
                Sku = sku,
                AdminSiteName = adminSiteName
            };

            if (!string.IsNullOrEmpty(aseName)
                && !string.IsNullOrEmpty(aseResourceGroupName))
            {
                serverFarm.HostingEnvironmentProfile = new HostingEnvironmentProfile
                {
                    Id = CmdletHelpers.GetApplicationServiceEnvironmentResourceId(WrappedWebsitesClient.SubscriptionId, aseResourceGroupName, aseName),
                    Type = CmdletHelpers.ApplicationServiceEnvironmentResourcesName,
                    Name = aseName
                };
            }

            return WrappedWebsitesClient.ServerFarms.CreateOrUpdateServerFarm(resourceGroupName, appServicePlanName, serverFarm);
        }
示例#24
0
        public AppServicePlan CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku, string aseName = null, string aseResourceGroupName = null, bool?perSiteScaling = false)
        {
            var appServicePlan = new AppServicePlan
            {
                Location           = location,
                AppServicePlanName = appServicePlanName,
                Sku            = sku,
                AdminSiteName  = adminSiteName,
                PerSiteScaling = perSiteScaling
            };

            if (!string.IsNullOrEmpty(aseName) &&
                !string.IsNullOrEmpty(aseResourceGroupName))
            {
                appServicePlan.HostingEnvironmentProfile = new HostingEnvironmentProfile(
                    id: CmdletHelpers.GetApplicationServiceEnvironmentResourceId(WrappedWebsitesClient.SubscriptionId, aseResourceGroupName, aseName),
                    name: aseName,
                    type: CmdletHelpers.ApplicationServiceEnvironmentResourcesName);
            }

            return(WrappedWebsitesClient.AppServicePlans().CreateOrUpdate(resourceGroupName, appServicePlanName, appServicePlan));
        }
示例#25
0
        public ServerFarmWithRichSku CreateAppServicePlan(string resourceGroupName, string appServicePlanName, string location, string adminSiteName, SkuDescription sku)
        {
            var serverFarm = new ServerFarmWithRichSku
            {
                Location = location,
                ServerFarmWithRichSkuName = appServicePlanName,
                Sku           = sku,
                AdminSiteName = adminSiteName
            };

            return(WrappedWebsitesClient.ServerFarms.CreateOrUpdateServerFarm(resourceGroupName, appServicePlanName, serverFarm));
        }
示例#26
0
 internal SkuInfo(string resourceType, SkuDescription sku, SkuCapacity capacity)
 {
     ResourceType = resourceType;
     Sku          = sku;
     Capacity     = capacity;
 }