From fedcf95594bbf1453a1e08b77d0d5ef79da9b319 Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Mon, 23 Oct 2023 13:49:37 +1100 Subject: [PATCH 1/4] [Modules] Updated App Service Plans API Version --- modules/web/serverfarm/main.bicep | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/web/serverfarm/main.bicep b/modules/web/serverfarm/main.bicep index 9a69b5e62c..ab515dbee6 100644 --- a/modules/web/serverfarm/main.bicep +++ b/modules/web/serverfarm/main.bicep @@ -20,8 +20,13 @@ param location string = resourceGroup().location @allowed([ 'Windows' 'Linux' + 'App' + 'Elastic' ]) -param serverOS string = 'Windows' +param kind string = 'Windows' + +@description('Optional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false.') +param reserved bool = false @description('Optional. The Resource ID of the App Service Environment to use for the App Service Plan.') param appServiceEnvironmentId string = '' @@ -108,9 +113,9 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena } } -resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = { +resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { name: name - kind: serverOS == 'Windows' ? '' : 'linux' + kind: kind location: location tags: tags sku: sku @@ -121,7 +126,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = { } : null perSiteScaling: perSiteScaling maximumElasticWorkerCount: maximumElasticWorkerCount - reserved: serverOS == 'Linux' + reserved: reserved targetWorkerCount: targetWorkerCount targetWorkerSizeId: targetWorkerSize zoneRedundant: zoneRedundant From 02e19e2d2fa6cbf6a215a6931cf4cda8dc9f5e88 Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:05:10 +1100 Subject: [PATCH 2/4] updated plans --- modules/web/serverfarm/main.bicep | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/web/serverfarm/main.bicep b/modules/web/serverfarm/main.bicep index ab515dbee6..91965799b6 100644 --- a/modules/web/serverfarm/main.bicep +++ b/modules/web/serverfarm/main.bicep @@ -18,10 +18,11 @@ param location string = resourceGroup().location @description('Optional. Kind of server OS.') @allowed([ - 'Windows' - 'Linux' 'App' 'Elastic' + 'FunctionApp' + 'Windows' + 'Linux' ]) param kind string = 'Windows' From b40455dd66ab3e58b0cd93811dee3a985265244f Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Tue, 24 Oct 2023 08:27:06 +1100 Subject: [PATCH 3/4] Updated JSON and README --- modules/web/serverfarm/README.md | 28 ++++++++++++++++++---------- modules/web/serverfarm/main.json | 22 ++++++++++++++++------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/modules/web/serverfarm/README.md b/modules/web/serverfarm/README.md index 1ce43a5618..bc6ac399dc 100644 --- a/modules/web/serverfarm/README.md +++ b/modules/web/serverfarm/README.md @@ -17,7 +17,7 @@ This module deploys an App Service Plan. | `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) | | `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) | | `Microsoft.Insights/diagnosticSettings` | [2021-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Insights/2021-05-01-preview/diagnosticSettings) | -| `Microsoft.Web/serverfarms` | [2021-02-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2021-02-01/serverfarms) | +| `Microsoft.Web/serverfarms` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Web/2022-09-01/serverfarms) | ## Usage examples @@ -169,12 +169,13 @@ module serverfarm 'br:bicep/modules/web.serverfarm:1.0.0' = { | [`diagnosticStorageAccountId`](#parameter-diagnosticstorageaccountid) | string | Resource ID of the diagnostic storage account. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub. | | [`diagnosticWorkspaceId`](#parameter-diagnosticworkspaceid) | string | Resource ID of the diagnostic log analytics workspace. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub. | | [`enableDefaultTelemetry`](#parameter-enabledefaulttelemetry) | bool | Enable telemetry via a Globally Unique Identifier (GUID). | +| [`kind`](#parameter-kind) | string | Kind of server OS. | | [`location`](#parameter-location) | string | Location for all resources. | | [`lock`](#parameter-lock) | object | The lock settings of the service. | | [`maximumElasticWorkerCount`](#parameter-maximumelasticworkercount) | int | Maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan. | | [`perSiteScaling`](#parameter-persitescaling) | bool | If true, apps assigned to this App Service plan can be scaled independently. If false, apps assigned to this App Service plan will scale to all instances of the plan. | +| [`reserved`](#parameter-reserved) | bool | When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false. | | [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. | -| [`serverOS`](#parameter-serveros) | string | Kind of server OS. | | [`tags`](#parameter-tags) | object | Tags of the resource. | | [`targetWorkerCount`](#parameter-targetworkercount) | int | Scaling worker count. | | [`targetWorkerSize`](#parameter-targetworkersize) | int | The instance size of the hosting plan (small, medium, or large). | @@ -238,6 +239,14 @@ Enable telemetry via a Globally Unique Identifier (GUID). - Type: bool - Default: `True` +### Parameter: `kind` + +Kind of server OS. +- Required: No +- Type: string +- Default: `'Windows'` +- Allowed: `[App, Elastic, FunctionApp, Linux, Windows]` + ### Parameter: `location` Location for all resources. @@ -292,6 +301,13 @@ If true, apps assigned to this App Service plan can be scaled independently. If - Type: bool - Default: `False` +### Parameter: `reserved` + +When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false. +- Required: No +- Type: bool +- Default: `False` + ### Parameter: `roleAssignments` Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. @@ -360,14 +376,6 @@ Required. The name of the role to assign. If it cannot be found you can specify - Required: Yes - Type: string -### Parameter: `serverOS` - -Kind of server OS. -- Required: No -- Type: string -- Default: `'Windows'` -- Allowed: `[Linux, Windows]` - ### Parameter: `sku` Defines the name, tier, size, family and capacity of the App Service Plan. diff --git a/modules/web/serverfarm/main.json b/modules/web/serverfarm/main.json index f35cc3c4b4..a1cdb40e4e 100644 --- a/modules/web/serverfarm/main.json +++ b/modules/web/serverfarm/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.22.6.54827", - "templateHash": "10390609619515936643" + "templateHash": "15409545856914828703" }, "name": "App Service Plans", "description": "This module deploys an App Service Plan.", @@ -127,10 +127,13 @@ "description": "Optional. Location for all resources." } }, - "serverOS": { + "kind": { "type": "string", "defaultValue": "Windows", "allowedValues": [ + "App", + "Elastic", + "FunctionApp", "Windows", "Linux" ], @@ -138,6 +141,13 @@ "description": "Optional. Kind of server OS." } }, + "reserved": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Optional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false." + } + }, "appServiceEnvironmentId": { "type": "string", "defaultValue": "", @@ -305,9 +315,9 @@ }, "appServicePlan": { "type": "Microsoft.Web/serverfarms", - "apiVersion": "2021-02-01", + "apiVersion": "2022-09-01", "name": "[parameters('name')]", - "kind": "[if(equals(parameters('serverOS'), 'Windows'), '', 'linux')]", + "kind": "[parameters('kind')]", "location": "[parameters('location')]", "tags": "[parameters('tags')]", "sku": "[parameters('sku')]", @@ -316,7 +326,7 @@ "hostingEnvironmentProfile": "[if(not(empty(parameters('appServiceEnvironmentId'))), createObject('id', parameters('appServiceEnvironmentId')), null())]", "perSiteScaling": "[parameters('perSiteScaling')]", "maximumElasticWorkerCount": "[parameters('maximumElasticWorkerCount')]", - "reserved": "[equals(parameters('serverOS'), 'Linux')]", + "reserved": "[parameters('reserved')]", "targetWorkerCount": "[parameters('targetWorkerCount')]", "targetWorkerSizeId": "[parameters('targetWorkerSize')]", "zoneRedundant": "[parameters('zoneRedundant')]" @@ -404,7 +414,7 @@ "metadata": { "description": "The location the resource was deployed into." }, - "value": "[reference('appServicePlan', '2021-02-01', 'full').location]" + "value": "[reference('appServicePlan', '2022-09-01', 'full').location]" } } } \ No newline at end of file From 9d9ca87655fbd17300909d9908079966d1a65681 Mon Sep 17 00:00:00 2001 From: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Date: Tue, 24 Oct 2023 08:38:22 +1100 Subject: [PATCH 4/4] Set reserved to conditional --- modules/web/serverfarm/README.md | 7 ++++++- modules/web/serverfarm/main.bicep | 2 +- modules/web/serverfarm/main.json | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/web/serverfarm/README.md b/modules/web/serverfarm/README.md index bc6ac399dc..63e124fbc3 100644 --- a/modules/web/serverfarm/README.md +++ b/modules/web/serverfarm/README.md @@ -157,6 +157,12 @@ module serverfarm 'br:bicep/modules/web.serverfarm:1.0.0' = { | [`name`](#parameter-name) | string | The name of the app service plan to deploy. | | [`sku`](#parameter-sku) | object | Defines the name, tier, size, family and capacity of the App Service Plan. | +**Conditional parameters** + +| Parameter | Type | Description | +| :-- | :-- | :-- | +| [`reserved`](#parameter-reserved) | bool | When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false. | + **Optional parameters** | Parameter | Type | Description | @@ -174,7 +180,6 @@ module serverfarm 'br:bicep/modules/web.serverfarm:1.0.0' = { | [`lock`](#parameter-lock) | object | The lock settings of the service. | | [`maximumElasticWorkerCount`](#parameter-maximumelasticworkercount) | int | Maximum number of total workers allowed for this ElasticScaleEnabled App Service Plan. | | [`perSiteScaling`](#parameter-persitescaling) | bool | If true, apps assigned to this App Service plan can be scaled independently. If false, apps assigned to this App Service plan will scale to all instances of the plan. | -| [`reserved`](#parameter-reserved) | bool | When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false. | | [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalId' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. | | [`tags`](#parameter-tags) | object | Tags of the resource. | | [`targetWorkerCount`](#parameter-targetworkercount) | int | Scaling worker count. | diff --git a/modules/web/serverfarm/main.bicep b/modules/web/serverfarm/main.bicep index ebc4f3ba0d..342503d5f1 100644 --- a/modules/web/serverfarm/main.bicep +++ b/modules/web/serverfarm/main.bicep @@ -26,7 +26,7 @@ param location string = resourceGroup().location ]) param kind string = 'Windows' -@description('Optional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false.') +@description('Conditional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false.') param reserved bool = false @description('Optional. The Resource ID of the App Service Environment to use for the App Service Plan.') diff --git a/modules/web/serverfarm/main.json b/modules/web/serverfarm/main.json index a1cdb40e4e..a7e447770f 100644 --- a/modules/web/serverfarm/main.json +++ b/modules/web/serverfarm/main.json @@ -6,7 +6,7 @@ "_generator": { "name": "bicep", "version": "0.22.6.54827", - "templateHash": "15409545856914828703" + "templateHash": "4349826726843363999" }, "name": "App Service Plans", "description": "This module deploys an App Service Plan.", @@ -145,7 +145,7 @@ "type": "bool", "defaultValue": false, "metadata": { - "description": "Optional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false." + "description": "Conditional. When creating a Linux App Service Plan, the reserved field must be set to true, and when creating a Windows/app App Service Plan the reserved field must be set to false." } }, "appServiceEnvironmentId": {