azure - 将数组类型作为参数传递给 AppService 插槽的应用程序设置时出错

标签 azure runtime-error

使用“数组”类型的参数替换为网站槽应用程序设置的 AppService 部署失败,并出现以下错误。

2019-10-20T10:25:46.0572018Z ##[error]BadRequest: {
  "Code": "BadRequest",
  "Message": "HTTP request body must not be empty.",
  "Target": null,
  "Details": [
    {
      "Message": "HTTP request body must not be empty."
    },
    {
      "Code": "BadRequest"
    },
    {
      "ErrorEntity": {
        "ExtendedCode": "51016",
        "MessageTemplate": "HTTP request body must not be empty.",
        "Parameters": [],
        "Code": "BadRequest",
        "Message": "HTTP request body must not be empty."
      }
    }
  ],
  "Innererror": null
}

使用的模板如下。当 Email__ToEmailAddress 参数更改为字符串类型时,部署会成功,但作为数组类型时,部署会失败。传递一个空数组或具有多个值的数组没有区别。

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": { 
    "aseName": {
      "type": "string"
    },
    "hostingPlanName": {
      "type": "string"
    },
    "webAppName": {
      "type": "string"
    },
    "appInsightsLocation": {
      "type": "string"
    },
    "slotName": {
      "type": "string"
    },
    "gatewayIPAddressRestriction": {
      "type": "string"
    },
    "containerRegistryName": {
      "type": "string"
    },
    "containerImageName": {
      "type": "string"
    },
    "containerRegistryResourceGroup": {
      "type": "string"
    },
    "vNetName": {
      "defaultValue": "",
      "type": "string"
    },
    "vNetResourceGroupName": {
      "defaultValue": "",
      "type": "string"
    },
    "Email__ToEmailAddress": {
      "defaultValue": [
        "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b7d2dad6dedbf7d3d8dad6ded999d4d8da" rel="noreferrer noopener nofollow">[email protected]</a>"
      ],
      "type": "array"
    },
    "Email__FromEmailAddress": {
      "defaultValue": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0d5ddd1d9dcf0d4dfddd1d9de9ed3dfdd" rel="noreferrer noopener nofollow">[email protected]</a>",
      "type": "string"
    },
    "Email__SmtpServerPort": {
      "defaultValue": 2525,
      "type": "int"
    },
    "Email__IsAuthenticationRequired": {
      "defaultValue": false,
      "type": "bool"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Web/sites",
      "apiVersion": "2018-02-01",
      "name": "[tolower(parameters('webAppName'))]",
      "location": "[resourceGroup().location]",
      "tags": {
        "[concat('hidden-related:', '/subscriptions/', subscription().subscriptionId,'/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', tolower(parameters('hostingPlanName')))]": "empty"
      },
      "resources": [
        {
          "apiVersion": "2016-08-01",
          "type": "config",
          "name": "web",
          "dependsOn": [
            "[tolower(parameters('webAppName'))]"
          ]
        }
      ],
      "properties": {
        "name": "[tolower(parameters('webAppName'))]",
        "serverFarmId": "[concat('/subscriptions/', subscription().subscriptionId,'/resourcegroups/', resourceGroup().name, '/providers/Microsoft.Web/serverfarms/', tolower(parameters('hostingPlanName')))]",
        "hostingEnvironment": "[parameters('aseName')]"
      },
      "dependsOn": [
        "[resourceId('microsoft.insights/components/', tolower(parameters('webAppName')))]"
      ]
    },
    {
      "apiVersion": "2016-08-01",
      "type": "Microsoft.Web/sites/slots",
      "name": "[concat(tolower(parameters('webAppName')), '/', tolower(parameters('slotName')))]",
      "location": "[resourceGroup().location]",
      "comments": "This specifies the app service slot deployed to.",
      "tags": {
        "displayName": "Slot"
      },
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
        "siteConfig": {
          "appSettings": [
            {
              "name": "Email__ToEmailAddress",
              "value": "[parameters('Email__ToEmailAddress')]"
            },
            {
              "name": "Email__FromEmailAddress",
              "value": "[parameters('Email__FromEmailAddress')]"
            },
            {
              "name": "Email__SmtpServerPort",
              "value": "[parameters('Email__SmtpServerPort')]"
            },
            {
              "name": "Email__IsAuthenticationRequired",
              "value": "[parameters('Email__IsAuthenticationRequired')]"
            }
          ],
          "linuxFxVersion": "[concat('DOCKER|', reference(resourceId(parameters('containerRegistryResourceGroup'), 'Microsoft.ContainerRegistry/registries', parameters('containerRegistryName')), '2017-10-01').loginServer, '/', parameters('containerImageName'))]"
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', tolower(parameters('webAppName')))]"
      ]
    },
    {
      "type": "Microsoft.Insights/components",
      "name": "[tolower(parameters('webAppName'))]",
      "apiVersion": "2014-04-01",
      "location": "[parameters('appInsightsLocation')]",
      "tags": {
        "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', tolower(parameters('webAppName')))]": "Resource"
      },
      "properties": {
        "applicationId": "[tolower(parameters('webAppName'))]",
        "Request_Source": "AzureTfsExtensionAzureProject"
      }
    }
  ]
}

感谢所有回复。

最佳答案

这可能与参数函数解析数组的方式有关。

尝试:

[数组(参数('Email__ToEmailAddress'))]

或者:

[[参数('Email__ToEmailAddress')]]

希望这有帮助。

关于azure - 将数组类型作为参数传递给 AppService 插槽的应用程序设置时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58472169/

相关文章:

azure - Terraform CLI 出现错误 : ID was missing the `slots` element

react-native - react native 错误: Super expression must either be null or a function

azure - 如何将另一个服务主体作为所有者添加到应用程序注册

azure - 默认情况下,.NET Core 服务和站点的 Application Insights 是否处于启用状态?

sql-server-2008 - 在 Azure 中导入 SQL Server 2008 数据库

c# - 使用现有数据库的 Azure 移动应用程序

linux - 可用性集不在下拉列表中

vba - Err.Raise 的 COM 错误号在哪里注册?

ruby - 无法使用 Require 加载模块

java - 我在这个java程序中找不到运行时错误(NZEC)