首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不通过Bicep模板创建defaultDocuments设置

不通过Bicep模板创建defaultDocuments设置
EN

Stack Overflow用户
提问于 2022-08-31 14:32:06
回答 1查看 28关注 0票数 0

我有一个二头肌模板来创建AppService计划和WebApp。我正在使用SiteConfig设置来设置默认文档,我尝试通过Microsoft.Web/sites@2020-06-01以及通过Microsoft.Web/sites/config@2022-03-01添加这些设置,但是没有任何运气。我已经尝试搜索,看看在设置defaultDocuments时是否丢失了什么东西,但是找不到任何东西。这里有人知道为什么我的模板没有设置默认文档吗?当我通过Visual创建时,我能够看到它们,但我需要通过二头肌来实现它。在创建AppService via VS之后,我还查看了模板,以确保我做的是正确的,我没有看到任何区别。

代码语言:javascript
运行
复制
@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'
    ]
  }
}
EN

回答 1

Stack Overflow用户

发布于 2022-08-31 16:14:07

在您的defaultDocuments中设置appService_name_web应该可以工作,但我相信您的appService内部有一些古怪的配置。我们将对appService做一些小小的修改,并尝试将您的配置移到appService_name_web部分。

代码语言:javascript
运行
复制
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
  }
}

然后在您的配置中:

代码语言:javascript
运行
复制
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部分:

代码语言:javascript
运行
复制
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'
     }
  }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73557539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档