Reputation: 333
I have a bicep template that creates the AppService Plan and the WebApp. I'm playing around with the SiteConfig settings to setup Default Documents, I've tried adding that via Microsoft.Web/sites@2020-06-01 as well as via Microsoft.Web/sites/config@2022-03-01' but haven't had any luck. I've tried searching to see if there is something I am missing when setting up defaultDocuments but couldn't find anything. Does anyone here know why my template isn't setting defaultdocuments? I am able to see them when I create the App Service via Visual studio but I need to do it via bicep. After creating the AppService via VS, I also looked at the template to make sure I was doing it correctly and I dont see any differences.
@description('Web app name.')
@minLength(2)
param appServiceName string = 'QSCloudDashboard' // Generate unique String for web app name
@description('Describes plan\'s pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/')
@allowed([
'F1'
'D1'
'B1'
'B2'
'B3'
'S1'
'S2'
'S3'
'P1'
'P2'
'P3'
'P4'
])
param sku string = 'B2' // The SKU of App Service Plan
param location string = resourceGroup().location // Location for all resources
@description('The language stack of the app.')
@allowed([
'.net'
'php'
'node'
'html'
])
param language string = '.net'
var configReference = {
'.net': {
comments: '.Net app. No additional configuration needed.'
}
html: {
comments: 'HTML app. No additional configuration needed.'
}
php: {
phpVersion: '7.4'
}
}
var appServicePlanName = toLower('${appServiceName}-AppServicePlan')
resource appServicePlan 'Microsoft.Web/serverfarms@2020-06-01' = {
name: appServicePlanName
location: location
properties: {
reserved: true
}
sku: {
name: sku
}
}
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: appServiceName
location: location
kind: 'app'
identity: {
type: 'SystemAssigned'
}
properties: {
enabled: true
siteConfig: union(configReference[language],{
minTlsVersion: '1.2'
linuxFxVersion: 'DOTNETCORE|6.0'
//netFrameworkVersion:'dotnet'
//numberOfWorkers: 1
// defaultDocuments: [
// 'Default.htm'
// 'Default.html'
// 'Default.asp'
// 'index.htm'
// 'index.html'
// 'iisstart.htm'
// 'default.aspx'
// 'index.php'
// 'hostingstart.html'
// ]
scmMinTlsVersion: '1.2'
ftpsState: 'AllAllowed'
acrUseManagedIdentityCreds: false
alwaysOn: false
http20Enabled: false
functionAppScaleLimit: 0
minimumElasticInstanceCount: 0
appSettings: [
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '6.9.1'
}
{
name: 'APPINSIGHTS_CONNECTIONSTRING'
value: 'InstrumentationKey=1caef12c-6950-4ffb-9edf-d552e0b84643;IngestionEndpoint=https://eastus-5.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/'
}
{
name: 'ApplicationInsightsAgent_EXTENSION_VERSION'
value: '~2'
}
{
name: 'DiagnosticServices_EXTENSION_VERSION'
value: '~3'
}
]
})
serverFarmId: appServicePlan.id
reserved: false
isXenon: false
hyperV: false
httpsOnly: true
scmSiteAlsoStopped: false
clientAffinityEnabled: true
clientCertEnabled: false
clientCertMode: 'Required'
hostNamesDisabled: false
containerSize: 0
dailyMemoryTimeQuota: 0
redundancyMode: 'None'
}
}
resource appService_name_web 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService
name: 'web'
location: 'East US'
properties: {
numberOfWorkers: 1
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
'hostingstart.html'
]
}
}
Upvotes: 0
Views: 197
Reputation: 237
Setting defaultDocuments in your appService_name_web should work, but I believe your appService had some funky config inside of it. A few small changes, we'll simplify appService a bit and try moving your config to your appService_name_web section.
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: appServiceName
location: location
kind: 'app'
identity: {
type: 'SystemAssigned'
}
properties: {
enabled: true
siteConfig: {
alwaysOn: true
defaultDocuments: []
}
httpsOnly: true
serverFarmId: appServicePlan.id
clientAffinityEnabled: true
clientCertEnabled: false
}
}
Then in your config:
resource appService_name_web 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService
name: 'web'
properties: {
numberOfWorkers: 1
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
'hostingstart.html'
]
minTlsVersion: '1.2'
linuxFxVersion: 'DOTNETCORE|6.0'
scmMinTlsVersion: '1.2'
ftpsState: 'AllAllowed'
acrUseManagedIdentityCreds: false
http20Enabled: false
functionAppScaleLimit: 0
minimumElasticInstanceCount: 0
}
}
You can break out a new appSettings section as well if you'd like:
resource appService_name_web_appSettings 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService
name: 'appsettings'
properties: {
appSettings: {
'WEBSITE_NODE_DEFAULT_VERSION': '6.9.1'
'APPINSIGHTS_CONNECTIONSTRING': 'InstrumentationKey=1caef12c-6950-4ffb-9edf-d552e0b84643;IngestionEndpoint=https://eastus-5.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/'
'ApplicationInsightsAgent_EXTENSION_VERSION': '~2'
'DiagnosticServices_EXTENSION_VERSION': '~3'
}
}
Upvotes: 0