Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AppServicePlan - SKU selection improvements #1736

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 34 additions & 50 deletions avm/res/web/serverfarm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfmin001'
sku: {
capacity: 3
family: 'P'
name: 'P1v3'
size: 'P1v3'
tier: 'Premium'
}
skuCapacity: 2
skuName: 'S1'
// Non-required parameters
location: '<location>'
}
Expand All @@ -76,14 +71,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfmin001"
},
"sku": {
"value": {
"capacity": 3,
"family": "P",
"name": "P1v3",
"size": "P1v3",
"tier": "Premium"
}
"skuCapacity": {
"value": 2
},
"skuName": {
"value": "S1"
},
// Non-required parameters
"location": {
Expand Down Expand Up @@ -111,13 +103,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfmax001'
sku: {
capacity: 1
family: 'S'
name: 'S1'
size: 'S1'
tier: 'Standard'
}
skuCapacity: 1
skuName: 'S1'
// Non-required parameters
diagnosticSettings: [
{
Expand Down Expand Up @@ -183,14 +170,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfmax001"
},
"sku": {
"value": {
"capacity": 1,
"family": "S",
"name": "S1",
"size": "S1",
"tier": "Standard"
}
"skuCapacity": {
"value": 1
},
"skuName": {
"value": "S1"
},
// Non-required parameters
"diagnosticSettings": {
Expand Down Expand Up @@ -275,13 +259,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
params: {
// Required parameters
name: 'wsfwaf001'
sku: {
capacity: 3
family: 'P'
name: 'P1v3'
size: 'P1v3'
tier: 'Premium'
}
skuCapacity: 3
skuName: 'P1v3'
// Non-required parameters
diagnosticSettings: [
{
Expand Down Expand Up @@ -329,14 +308,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
"name": {
"value": "wsfwaf001"
},
"sku": {
"value": {
"capacity": 3,
"family": "P",
"name": "P1v3",
"size": "P1v3",
"tier": "Premium"
}
"skuCapacity": {
"value": 3
},
"skuName": {
"value": "P1v3"
},
// Non-required parameters
"diagnosticSettings": {
Expand Down Expand Up @@ -392,7 +368,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:<version>' = {
| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-name) | string | Name of the app service plan. |
| [`sku`](#parameter-sku) | object | Defines the name, tier, size, family and capacity of the App Service Plan. |
| [`skuCapacity`](#parameter-skucapacity) | int | Number of workers associated with the App Service Plan. |
| [`skuName`](#parameter-skuname) | string | The name of the SKU will Determine the tier, size, family of the App Service Plan. |

**Conditional parameters**

Expand Down Expand Up @@ -426,12 +403,19 @@ Name of the app service plan.
- Required: Yes
- Type: string

### Parameter: `sku`
### Parameter: `skuCapacity`

Defines the name, tier, size, family and capacity of the App Service Plan.
Number of workers associated with the App Service Plan.

- Required: Yes
- Type: object
- Type: int

### Parameter: `skuName`

The name of the SKU will Determine the tier, size, family of the App Service Plan.

- Required: Yes
- Type: string

### Parameter: `reserved`

Expand Down Expand Up @@ -778,7 +762,7 @@ Zone Redundancy can only be used on Premium or ElasticPremium SKU Tiers within Z

- Required: No
- Type: bool
- Default: `[if(or(equals(parameters('sku').tier, 'Premium'), equals(parameters('sku').tier, 'ElasticPremium')), true(), false())]`
- Default: `[if(or(startsWith(parameters('skuName'), 'P'), startsWith(parameters('skuName'), 'EP')), true(), false())]`


## Outputs
Expand Down
25 changes: 14 additions & 11 deletions avm/res/web/serverfarm/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ metadata owner = 'Azure/module-maintainers'
@maxLength(60)
param name string

@description('Required. Defines the name, tier, size, family and capacity of the App Service Plan.')
@description('Required. The name of the SKU will Determine the tier, size, family of the App Service Plan.')
@metadata({
example: '''
{
name: 'P1v3'
tier: 'Premium'
size: 'P1v3'
family: 'P'
capacity: 3
}
'F1'
'B1'
'P1v3'
'I1v2'
'''
})
param sku object
param skuName string

@description('Required. Number of workers associated with the App Service Plan.')
param skuCapacity int

@description('Optional. Location for all resources.')
param location string = resourceGroup().location
Expand Down Expand Up @@ -61,7 +61,7 @@ param targetWorkerCount int = 0
param targetWorkerSize int = 0

@description('Optional. Zone Redundancy can only be used on Premium or ElasticPremium SKU Tiers within ZRS Supported regions (https://learn.microsoft.com/en-us/azure/storage/common/redundancy-regions-zrs).')
param zoneRedundant bool = (sku.tier == 'Premium' || sku.tier == 'ElasticPremium') ? true : false
param zoneRedundant bool = startsWith(skuName, 'P') || startsWith(skuName, 'EP') ? true : false

@description('Optional. The lock settings of the service.')
param lock lockType
Expand Down Expand Up @@ -124,7 +124,10 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
kind: kind
location: location
tags: tags
sku: sku
sku: {
name: skuName
capacity: skuCapacity
}
properties: {
workerTierName: workerTierName
hostingEnvironmentProfile: !empty(appServiceEnvironmentId)
Expand Down
23 changes: 16 additions & 7 deletions avm/res/web/serverfarm/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "16669238654401736455"
"templateHash": "5846778493081554072"
},
"name": "App Service Plan",
"description": "This module deploys an App Service Plan.",
Expand Down Expand Up @@ -201,11 +201,17 @@
"description": "Required. Name of the app service plan."
}
},
"sku": {
"type": "object",
"skuName": {
"type": "string",
"metadata": {
"example": " {\n name: 'P1v3'\n tier: 'Premium'\n size: 'P1v3'\n family: 'P'\n capacity: 3\n }\n ",
"description": "Required. Defines the name, tier, size, family and capacity of the App Service Plan."
"example": " 'F1'\n 'B1'\n 'P1v3'\n 'I1v2'\n ",
"description": "Required. The name of the SKU will Determine the tier, size, family of the App Service Plan."
}
},
"skuCapacity": {
"type": "int",
"metadata": {
"description": "Required. Number of workers associated with the App Service Plan."
}
},
"location": {
Expand Down Expand Up @@ -285,7 +291,7 @@
},
"zoneRedundant": {
"type": "bool",
"defaultValue": "[if(or(equals(parameters('sku').tier, 'Premium'), equals(parameters('sku').tier, 'ElasticPremium')), true(), false())]",
"defaultValue": "[if(or(startsWith(parameters('skuName'), 'P'), startsWith(parameters('skuName'), 'EP')), true(), false())]",
"metadata": {
"description": "Optional. Zone Redundancy can only be used on Premium or ElasticPremium SKU Tiers within ZRS Supported regions (https://learn.microsoft.com/en-us/azure/storage/common/redundancy-regions-zrs)."
}
Expand Down Expand Up @@ -362,7 +368,10 @@
"kind": "[parameters('kind')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
"sku": "[parameters('sku')]",
"sku": {
"name": "[parameters('skuName')]",
"capacity": "[parameters('skuCapacity')]"
},
"properties": {
"workerTierName": "[parameters('workerTierName')]",
"hostingEnvironmentProfile": "[if(not(empty(parameters('appServiceEnvironmentId'))), createObject('id', parameters('appServiceEnvironmentId')), null())]",
Expand Down
9 changes: 2 additions & 7 deletions avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ module testDeployment '../../../main.bicep' = [
params: {
name: '${namePrefix}${serviceShort}001'
location: tempLocation
sku: {
name: 'P1v3'
tier: 'Premium'
size: 'P1v3'
family: 'P'
capacity: 3
}
skuName: 'S1'
skuCapacity: 2
}
}
]
9 changes: 2 additions & 7 deletions avm/res/web/serverfarm/tests/e2e/max/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ module testDeployment '../../../main.bicep' = [
params: {
name: '${namePrefix}${serviceShort}001'
location: tempLocation
sku: {
name: 'S1'
tier: 'Standard'
size: 'S1'
family: 'S'
capacity: 1
}
skuName: 'S1'
skuCapacity: 1
perSiteScaling: true
zoneRedundant: false
kind: 'App'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ module testDeployment '../../../main.bicep' = [
params: {
name: '${namePrefix}${serviceShort}001'
location: tempLocation
sku: {
name: 'P1v3'
tier: 'Premium'
size: 'P1v3'
family: 'P'
capacity: 3
}
skuName: 'P1v3'
skuCapacity: 3
zoneRedundant: true
kind: 'App'
lock: {
Expand Down
2 changes: 1 addition & 1 deletion avm/res/web/serverfarm/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.1",
"version": "0.2",
"pathFilters": [
"./main.json"
]
Expand Down