"Parameter x-ms-client-principal-name is null or empty" 在 VSTS 中使用源代码管理 link 部署 Function App 时

"Parameter x-ms-client-principal-name is null or empty" when deploying a Function App with Source Control link in VSTS

我想在我的 DEV/TEST/PROD 个实例中自动部署一个基于消费计划的 Function App。为此,我开始在 Portal 中手动创建一个 Function App,copy/pasted 自动化脚本并将其合并到我的 ARM 模板项目中。 为了将我的源代码自动部署到 Function App,我将 link 集成到模板中的 repo/branch:

        "resources": [
            {
                "apiVersion": "2015-08-01",
                "name": "web",
                "type": "sourcecontrols",
                "dependsOn": [
                    "[concat('Microsoft.Web/sites/', parameters('name'))]"
                ],
                "tags": {
                    "displayName": "fnSourceControl"
                },
                "properties": {
                    "repoUrl": "[parameters('repoUrl')]",
                    "branch": "[parameters('repoBranch')]",
                    "isManualIntegration": false
                }
            }
        ]

当从 VS 或命令行部署时,它工作正常。使用 Function App 创建资源组并将代码部署到其中:Magic! 但是,从 VSTS 发布定义部署时,部署失败并显示:

Resource Microsoft.Web/sites/sourcecontrols 'myFunctionApp/web' failed with message '{
  "Code": "BadRequest",
  "Message": "Parameter x-ms-client-principal-name is null or empty.",
  "Target": null,
  "Details": [
    {
      "Message": "Parameter x-ms-client-principal-name is null or empty."
    },
    {
      "Code": "BadRequest"
    },
    {
      "ErrorEntity": {
        "Code": "BadRequest",
        "Message": "Parameter x-ms-client-principal-name is null or empty.",
        "ExtendedCode": "51011",
        "MessageTemplate": "Parameter {0} is null or empty.",
        "Parameters": [
          "x-ms-client-principal-name"
        ],
        "InnerErrors": null
      }
    }
  ],
  "Innererror": null
}

此问题与 有关 'Microsoft.Storage/storageAccounts/providers/locks' 部署问题。我想它会朝着同一个方向发展。我不想让一个问题混合两个问题。

我与我们的专家交谈过,得到的答复是不支持使用服务主体设置 VSTS。原因是,对于 VSTS,我们模拟调用者并代表用户调用 VSTS api。为此,调用方需要是有效的 VSTS 帐户。使用服务主体时,您的身份不是有效的 VSTS 帐户。

请注意,这与您从 VSTS 发布定义进行部署无关。使用服务主体身份在本地部署时也会发生同样的情况。