在适用于 Linux 或 Windows 的 Azure Web 应用中更新或添加应用服务设置。
语法
# Azure App Service Settings v1
# Update/Add App settings an Azure Web App for Linux or Windows.
- task: AzureAppServiceSettings@1
  inputs:
    azureSubscription: # string. Alias: ConnectedServiceName. Required. Azure subscription. 
    appName: # string. Required. App Service name. 
    resourceGroupName: # string. Required. Resource group. 
    #slotName: 'production' # string. Slot. Default: production.
  # Application and Configuration Settings
    #appSettings: # string. App settings. 
    #generalSettings: # string. General settings. 
    #connectionStrings: # string. Connection Strings.
输入
              appName
               - 
              应用服务名称
              string。 必填。
输入或选择现有 Azure 应用服务的名称。
              resourceGroupName
               - 
              资源组
              string。 必填。
输入或选择包含上面指定的 Azure 应用服务的 Azure 资源组。
              slotName
               - 
              槽
              string。 默认值:production。
输入或选择现有槽口。 如果未选择槽,则会对 production 进行更改。
              appSettings
               - 
              应用设置
              string。
JSON 语法中的应用程序设置。 将包含空格的值括在双引号中。 有关详细信息,请参阅配置应用设置。
以下是 JSON 语法的示例:
[
   {
    "name": "key1",
    "value": "valueabcd",
    "slotSetting": false
   },
   {
    "name": "key2",
    "value": "valueefgh",
    "slotSetting": true
   }
]
              generalSettings
               - 
              常规设置
              string。
JSON 语法中的常规设置。 将包含空格的值括在双引号中。 有关可用属性的列表,请参阅 应用服务 SiteConfig 对象文档。 有关更多信息,请参阅 配置常规设置。
以下是 JSON 语法的示例:
[
   {
    "alwaysOn": true,
    "webSocketsEnabled": false
   }
]
              connectionStrings
               - 
              连接字符串
              string。
JSON 语法中的连接字符串。 将包含空格的值括在双引号中。 有关详细信息,请参阅 “配置连接字符串”。
以下是 JSON 语法的示例:
[
   {
    "name": "key1",
    "value": "valueabcd",
    "type": "MySql",
    "slotSetting": false
   },
   {
    "name": "key2",
    "value": "valueefgh",
    "type": "Custom",
    "slotSetting": true
   }
]
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。
注解
使用此任务可在 Web 应用程序或其任何部署槽位上使用 JSON 语法批量配置应用程序设置、连接字符串和其他常规设置。 该任务适用于运行 Windows、Linux 或 Mac 的跨平台 Azure Pipelines 代理。 该任务适用于基于 ASP.NET、ASP.NET Core、PHP、Java、Python、Go 和 Node.js 的 Web 应用程序。
例子
以下示例 YAML 代码片段将 Web 应用程序部署到在 Windows 上运行的 Azure Web 应用服务。
variables:
  azureSubscription: Contoso
  WebApp_Name: sampleWebApp
  # To ignore SSL error uncomment the below variable
  # VSTS_ARM_REST_IGNORE_SSL_ERRORS: true
steps:
- task: AzureWebApp@1
  displayName: Azure Web App Deploy
  inputs:
    azureSubscription: $(azureSubscription)
    appType: 'webApp'
    appName: $(WebApp_Name)
    package: $(System.DefaultWorkingDirectory)/**/*.zip
- task: AzureAppServiceSettings@1
  displayName: Azure App Service Settings
  inputs:
    azureSubscription: $(azureSubscription)
    appName: $(WebApp_Name)
    resourceGroupName: 'contoso-rg'
   # To deploy the settings on a slot, provide slot name as below. By default, the settings would be applied to the actual Web App (Production slot)
   # slotName: staging
    appSettings: |
      [
        {
          "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
          "value": "$(Key)",
          "slotSetting": false
        },
        {
          "name": "MYSQL_DATABASE_NAME",
          "value": "$(DB_Name)", 
          "slotSetting": false
        }
      ]
    generalSettings: |
      [
        {
          "alwaysOn": true,
          "webSocketsEnabled": false
        }
      ]
    connectionStrings: |
      [
        {
          "name": "MysqlCredentials",
          "value": "$(MySQl_ConnectionString)",
          "type": "MySql",
          "slotSetting": false
        }
      ]