diff --git a/code/appService/bicep/modules/appService.module.bicep b/code/appService/bicep/modules/appService.module.bicep index f325516..634121b 100644 --- a/code/appService/bicep/modules/appService.module.bicep +++ b/code/appService/bicep/modules/appService.module.bicep @@ -10,7 +10,7 @@ param appInsightsInstrumentationKey string param language string -resource appService 'Microsoft.Web/sites@2022-03-01' = { +resource appService 'Microsoft.Web/sites@2023-01-01' = { name: toLower('app-${appServiceName}') location: location identity: { @@ -29,7 +29,7 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = { } } -resource appServiceLogging 'Microsoft.Web/sites/config@2022-03-01' = { +resource appServiceLogging 'Microsoft.Web/sites/config@2023-01-01' = { parent: appService name: 'appsettings' properties: { diff --git a/code/appService/bicep/modules/appServicePlan.module.bicep b/code/appService/bicep/modules/appServicePlan.module.bicep index d5403e0..9dd2903 100644 --- a/code/appService/bicep/modules/appServicePlan.module.bicep +++ b/code/appService/bicep/modules/appServicePlan.module.bicep @@ -39,7 +39,7 @@ param appServicePlanSKU string = 'D1' @allowed(['windows','linux','windowscontainer']) param appServiceKind string = 'windows' -resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = { +resource appServicePlan 'Microsoft.Web/serverfarms@2023-01-01' = { name: toLower('asp-${appServicePlanName}') location: location kind: appServiceKind diff --git a/code/appService/bicep/modules/logAnalytics.module.bicep b/code/appService/bicep/modules/logAnalytics.module.bicep index 392a507..0a73fe4 100644 --- a/code/appService/bicep/modules/logAnalytics.module.bicep +++ b/code/appService/bicep/modules/logAnalytics.module.bicep @@ -7,7 +7,7 @@ param retentionDays int = 30 @description('What Language was used to deploy this resource') param language string -resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = { +resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { name: toLower('la-${logAnalyticsName}') location: location tags: { diff --git a/code/appService/bicep_avm/main.bicep b/code/appService/bicep_avm/main.bicep new file mode 100644 index 0000000..8f991c3 --- /dev/null +++ b/code/appService/bicep_avm/main.bicep @@ -0,0 +1,112 @@ +@description('Base name that will appear for all resources.') +param baseName string = 'iacflavorsbicepAVM' +@description('Location for all resources.') +param location string + +@description('App Insights Type') +param appInsightsType string = 'web' +@description('Desired App Service Kind') +param appServicePlanKind string = 'Windows' +@description('App Service Plan Sku') +param appServicePlanSKU object +@description('Desired App Kind') +param appServiceKind string = 'app' +@description('Three letter environment abreviation to denote environment that will appear in all resource names') +param environmentName string = 'dev' +@description('Use Resource Permissions for Log Analytics') +param LogAnalyticsUseResourcePermissions bool = true +@description('How many days to retain Log Analytics Logs') +param retentionDays int + +targetScope = 'subscription' + +var regionReference = { + centralus: 'cus' + eastus: 'eus' + westus: 'wus' + westus2: 'wus2' +} +var nameSuffix = toLower('${baseName}-${environmentName}-${regionReference[location]}') +var language = 'Bicep' + +/* Since we are mismatching scopes with a deployment at subscription and resource at Resource Group + the main.bicep requires a resource Group deployed at the subscription scope, all modules will be at the Resource Group scope + */ + + resource resourceGroup 'Microsoft.Resources/resourceGroups@2023-07-01' ={ + location: location + name: toLower('rg-${nameSuffix}') + tags:{ + Customer: 'FlavorsIaC' + Language: language + } +} + +module appServicePlan 'br/public:avm/res/web/serverfarm:0.1.1' ={ + name: 'appServicePlanModule' + scope: resourceGroup + params:{ + name: 'asp-${nameSuffix}' + kind: appServicePlanKind + sku: appServicePlanSKU + tags:{ + Customer: 'FlavorsIaC' + Language: language + } + } +} + +module logAnalytics 'br/public:avm/res/operational-insights/workspace:0.3.4' ={ + name: 'logAnalyticsModule' + scope: resourceGroup + params:{ + name: 'la-${nameSuffix}' + tags: { + displayName: 'Log Analytics' + Language: language + } + useResourcePermissions: LogAnalyticsUseResourcePermissions + dataRetention: retentionDays + } +} +module appInsights 'br/public:avm/res/insights/component:0.3.0' ={ + name: 'appInsightsModule' + scope: resourceGroup + params:{ + applicationType: appInsightsType + name: 'ai-${nameSuffix}' + tags: { + displayName: 'AppInsight' + Language: language + } + workspaceResourceId: logAnalytics.outputs.resourceId + } +} + +module appService 'br/public:avm/res/web/site:0.3.2' ={ + name: 'appServiceModule' + scope: resourceGroup + params:{ + + name: 'app-${nameSuffix}' + appInsightResourceId: appInsights.outputs.resourceId + kind: appServiceKind + managedIdentities: { + systemAssigned: true + } + serverFarmResourceId: appServicePlan.outputs.resourceId + siteConfig: { + minTlsVersion: '1.2' + } + tags:{ + displayName: 'Website' + Language: language + } + } +} + + + + + + diff --git a/code/appService/bicep_avm/parameters/dev.eus.bicepparam b/code/appService/bicep_avm/parameters/dev.eus.bicepparam new file mode 100644 index 0000000..7430d39 --- /dev/null +++ b/code/appService/bicep_avm/parameters/dev.eus.bicepparam @@ -0,0 +1,11 @@ +using '../main.bicep' +param location = 'eastus' +param retentionDays = 30 +param appServicePlanSKU = { + name: 'D1' + tier: 'Shared' + size: 'D1' + family: 'D' + capacity: 0 + } +