Files
azure-examples/.bicep/modules/appService2.bicep
2026-01-28 10:29:49 -06:00

109 lines
2.3 KiB
Bicep

@description('The location for all resources')
param location string
@description('The name of the App Service Plan')
param appServicePlanName string
@description('The name of the Web App')
param webAppName string
@description('Application Insights Instrumentation Key')
param appInsightsInstrumentationKey string
@description('Application Insights Connection String')
param appInsightsConnectionString string
// Create App Service Plan
resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
name: appServicePlanName
location: location
sku: {
name: 'B1'
tier: 'Basic'
size: 'B1'
family: 'B'
capacity: 1
}
kind: 'linux'
properties: {
reserved: true
}
}
// Create Web App
resource webApp 'Microsoft.Web/sites@2022-09-01' = {
name: webAppName
location: location
kind: 'app,linux'
properties: {
serverFarmId: appServicePlan.id
httpsOnly: true
siteConfig: {
linuxFxVersion: 'DOTNETCORE|8.0'
alwaysOn: true
minTlsVersion: '1.2'
ftpsState: 'Disabled'
http20Enabled: true
appSettings: [
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: appInsightsConnectionString
}
{
name: 'ApplicationInsightsAgent_EXTENSION_VERSION'
value: '~3'
}
{
name: 'XDT_MicrosoftApplicationInsights_Mode'
value: 'recommended'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appInsightsInstrumentationKey
}
{
name: 'ASPNETCORE_ENVIRONMENT'
value: 'Production'
}
]
metadata: [
{
name: 'CURRENT_STACK'
value: 'dotnet'
}
]
}
}
}
// Enable detailed error messages and logging
resource webAppLogs 'Microsoft.Web/sites/config@2022-09-01' = {
parent: webApp
name: 'logs'
properties: {
applicationLogs: {
fileSystem: {
level: 'Information'
}
}
httpLogs: {
fileSystem: {
retentionInMb: 35
retentionInDays: 7
enabled: true
}
}
failedRequestsTracing: {
enabled: true
}
detailedErrorMessages: {
enabled: true
}
}
}
// Outputs
output webAppName string = webApp.name
output webAppUrl string = 'https://${webApp.properties.defaultHostName}'
output webAppId string = webApp.id