Skip to content

Commit

Permalink
Update appService and appServicePlan resources to use latest API vers…
Browse files Browse the repository at this point in the history
…ions (#70)

* Update appService and appServicePlan resources to use latest API versions

* Adding AVM for Bicep App Service
  • Loading branch information
JFolberth authored Apr 16, 2024
1 parent aa414cd commit 169b563
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 4 deletions.
4 changes: 2 additions & 2 deletions code/appService/bicep/modules/appService.module.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion code/appService/bicep/modules/appServicePlan.module.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/appService/bicep/modules/logAnalytics.module.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
112 changes: 112 additions & 0 deletions code/appService/bicep_avm/main.bicep
Original file line number Diff line number Diff line change
@@ -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
}
}
}






11 changes: 11 additions & 0 deletions code/appService/bicep_avm/parameters/dev.eus.bicepparam
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 169b563

Please sign in to comment.