我有一个二头肌模板,用于创建AppService Plan和WebApp。我正在使用SiteConfig设置来设置默认文档,我已经尝试通过Microsoft添加了它。Web/sites@2020-06-01以及通过微软。网站/config@2022-03-01但是运气不好。在设置defaultDocuments时,我尝试过搜索是否有遗漏的内容,但找不到任何内容。这里有人知道为什么我的模板没有设置defaultdocuments吗?当我通过Visual studio创建应用程序服务时,我可以看到它们,但我需要通过二头肌来完成。在通过VS创建AppService之后,我还查看了模板,以确保我做得正确,并且没有发现任何差异。
@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'
]
}
}
在appService_name_web中设置defaultDocuments应该可以,但我相信你的appService内部有一些时髦的配置。通过一些小的更改,我们将稍微简化appService,并尝试将配置移到appService_name_web部分。
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
}
}
然后在您的配置中:
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
}
}
如果你愿意,你也可以打开一个新的appSettings部分:
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'
}
}