From bb4380932b5dca3e210ef8647898870a18c64307 Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 12:56:41 +1200 Subject: [PATCH 1/7] Initial Logic --- avm/res/web/serverfarm/main.bicep | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/avm/res/web/serverfarm/main.bicep b/avm/res/web/serverfarm/main.bicep index 5deb3fe099..b0e0579ffd 100644 --- a/avm/res/web/serverfarm/main.bicep +++ b/avm/res/web/serverfarm/main.bicep @@ -21,6 +21,8 @@ param name string }) param sku object +param skuName string + @description('Optional. Location for all resources.') param location string = resourceGroup().location @@ -124,7 +126,15 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { kind: kind location: location tags: tags - sku: sku + sku: { + name: skuName + tier: contains(skuName, 'P') + ? 'Premium' + : contains(skuName, 'I') ? 'Isolated' : contains(skuName, 'E') ? 'ElasticPremium' : null + size: sku.size + family: sku.family + capacity: sku.capacity + } properties: { workerTierName: workerTierName hostingEnvironmentProfile: !empty(appServiceEnvironmentId) From e6dc559ab03a4ec6d0d82ec1cbf27bffecf064f3 Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 15:31:25 +1200 Subject: [PATCH 2/7] Tests updated and readmes done. Includes param changes to simplify SKU --- avm/res/web/serverfarm/README.md | 84 ++++++++----------- avm/res/web/serverfarm/main.bicep | 27 +++--- avm/res/web/serverfarm/main.json | 23 +++-- .../tests/e2e/defaults/main.test.bicep | 11 +-- .../serverfarm/tests/e2e/max/main.test.bicep | 9 +- .../tests/e2e/waf-aligned/main.test.bicep | 9 +- 6 files changed, 67 insertions(+), 96 deletions(-) diff --git a/avm/res/web/serverfarm/README.md b/avm/res/web/serverfarm/README.md index 1a3e585904..5b1ddb8b9d 100644 --- a/avm/res/web/serverfarm/README.md +++ b/avm/res/web/serverfarm/README.md @@ -47,13 +47,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { params: { // Required parameters name: 'wsfmin001' - sku: { - capacity: 3 - family: 'P' - name: 'P1v3' - size: 'P1v3' - tier: 'Premium' - } + skuCapacity: 1 + skuName: 'B1' // Non-required parameters location: '' } @@ -76,14 +71,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { "name": { "value": "wsfmin001" }, - "sku": { - "value": { - "capacity": 3, - "family": "P", - "name": "P1v3", - "size": "P1v3", - "tier": "Premium" - } + "skuCapacity": { + "value": 1 + }, + "skuName": { + "value": "B1" }, // Non-required parameters "location": { @@ -111,13 +103,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { params: { // Required parameters name: 'wsfmax001' - sku: { - capacity: 1 - family: 'S' - name: 'S1' - size: 'S1' - tier: 'Standard' - } + skuCapacity: 1 + skuName: 'S1' // Non-required parameters diagnosticSettings: [ { @@ -183,14 +170,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { "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": { @@ -275,13 +259,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { params: { // Required parameters name: 'wsfwaf001' - sku: { - capacity: 3 - family: 'P' - name: 'P1v3' - size: 'P1v3' - tier: 'Premium' - } + skuCapacity: 3 + skuName: 'P1v3' // Non-required parameters diagnosticSettings: [ { @@ -329,14 +308,11 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { "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": { @@ -392,7 +368,8 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { | 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** @@ -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` @@ -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 diff --git a/avm/res/web/serverfarm/main.bicep b/avm/res/web/serverfarm/main.bicep index b0e0579ffd..5eb7e567b6 100644 --- a/avm/res/web/serverfarm/main.bicep +++ b/avm/res/web/serverfarm/main.bicep @@ -7,22 +7,20 @@ 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 @@ -63,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 @@ -128,12 +126,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { tags: tags sku: { name: skuName - tier: contains(skuName, 'P') - ? 'Premium' - : contains(skuName, 'I') ? 'Isolated' : contains(skuName, 'E') ? 'ElasticPremium' : null - size: sku.size - family: sku.family - capacity: sku.capacity + capacity: skuCapacity } properties: { workerTierName: workerTierName diff --git a/avm/res/web/serverfarm/main.json b/avm/res/web/serverfarm/main.json index 68999ed0f2..1e9678c755 100644 --- a/avm/res/web/serverfarm/main.json +++ b/avm/res/web/serverfarm/main.json @@ -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.", @@ -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": { @@ -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)." } @@ -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())]", diff --git a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep index 9f2ffe8e94..4ea37f5005 100644 --- a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep @@ -21,7 +21,7 @@ param serviceShort string = 'wsfmin' param namePrefix string = '#_namePrefix_#' #disable-next-line no-hardcoded-location // Just a value to avoid ongoing capacity challenges -var tempLocation = 'eastus' +var tempLocation = 'australiaeast' // ============ // // Dependencies // @@ -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: 'B1' + skuCapacity: 1 } } ] diff --git a/avm/res/web/serverfarm/tests/e2e/max/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/max/main.test.bicep index f7e0fb3a88..b987bfb1ae 100644 --- a/avm/res/web/serverfarm/tests/e2e/max/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/max/main.test.bicep @@ -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' diff --git a/avm/res/web/serverfarm/tests/e2e/waf-aligned/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/waf-aligned/main.test.bicep index 5cd23e57c9..45080f9d3b 100644 --- a/avm/res/web/serverfarm/tests/e2e/waf-aligned/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/waf-aligned/main.test.bicep @@ -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: { From 83fe1f677c1f697525b0bbbf620e1e7b21d9b951 Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 15:43:56 +1200 Subject: [PATCH 3/7] test update --- avm/res/web/serverfarm/README.md | 4 ++-- avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/avm/res/web/serverfarm/README.md b/avm/res/web/serverfarm/README.md index 5b1ddb8b9d..925643e00d 100644 --- a/avm/res/web/serverfarm/README.md +++ b/avm/res/web/serverfarm/README.md @@ -47,7 +47,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { params: { // Required parameters name: 'wsfmin001' - skuCapacity: 1 + skuCapacity: 2 skuName: 'B1' // Non-required parameters location: '' @@ -72,7 +72,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { "value": "wsfmin001" }, "skuCapacity": { - "value": 1 + "value": 2 }, "skuName": { "value": "B1" diff --git a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep index 4ea37f5005..2e6a92dd69 100644 --- a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep @@ -47,7 +47,7 @@ module testDeployment '../../../main.bicep' = [ name: '${namePrefix}${serviceShort}001' location: tempLocation skuName: 'B1' - skuCapacity: 1 + skuCapacity: 2 } } ] From a2e315a840f7c06f45a91db625d2be381b22d43c Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 19:27:49 +1200 Subject: [PATCH 4/7] Min Plan Rule --- avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep index 2e6a92dd69..703eef9530 100644 --- a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep @@ -46,7 +46,7 @@ module testDeployment '../../../main.bicep' = [ params: { name: '${namePrefix}${serviceShort}001' location: tempLocation - skuName: 'B1' + skuName: 'S1' skuCapacity: 2 } } From 76b77639e7fb56b32f1124bb706c62f4227d012b Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 19:29:53 +1200 Subject: [PATCH 5/7] correcting readme with test info. --- avm/res/web/serverfarm/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avm/res/web/serverfarm/README.md b/avm/res/web/serverfarm/README.md index 925643e00d..74b625e14a 100644 --- a/avm/res/web/serverfarm/README.md +++ b/avm/res/web/serverfarm/README.md @@ -48,7 +48,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { // Required parameters name: 'wsfmin001' skuCapacity: 2 - skuName: 'B1' + skuName: 'S1' // Non-required parameters location: '' } @@ -75,7 +75,7 @@ module serverfarm 'br/public:avm/res/web/serverfarm:' = { "value": 2 }, "skuName": { - "value": "B1" + "value": "S1" }, // Non-required parameters "location": { From 456cc69fdebafa46fc1cd9716e284d4f64ed8120 Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Mon, 22 Apr 2024 19:52:53 +1200 Subject: [PATCH 6/7] updated location and ran set module. --- avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep index 703eef9530..0183742502 100644 --- a/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep +++ b/avm/res/web/serverfarm/tests/e2e/defaults/main.test.bicep @@ -21,7 +21,7 @@ param serviceShort string = 'wsfmin' param namePrefix string = '#_namePrefix_#' #disable-next-line no-hardcoded-location // Just a value to avoid ongoing capacity challenges -var tempLocation = 'australiaeast' +var tempLocation = 'eastus' // ============ // // Dependencies // From 157fddeebe767ea2c74a7983308ca3034b97095b Mon Sep 17 00:00:00 2001 From: BuddyDavies Date: Tue, 23 Apr 2024 10:14:31 +1200 Subject: [PATCH 7/7] version bumped up to align to changes --- avm/res/web/serverfarm/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avm/res/web/serverfarm/version.json b/avm/res/web/serverfarm/version.json index 8def869ede..daf1a794d9 100644 --- a/avm/res/web/serverfarm/version.json +++ b/avm/res/web/serverfarm/version.json @@ -1,6 +1,6 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.1", + "version": "0.2", "pathFilters": [ "./main.json" ]