【问题标题】:Error when deploying custom template in Azure from Azure DevOps repo ("deploy to azure" button)从 Azure DevOps 存储库在 Azure 中部署自定义模板时出错(“部署到 azure”按钮)
【发布时间】:2021-04-07 21:58:45
【问题描述】:

全部,

我正在尝试使用“部署到 Azure”按钮,使用存储在 Azure DevOps Git 存储库中的模板。
我收到以下错误:
Error parsing template. Please ensure template is valid JSON. Invalid symbol at character position 4. (3 other errors).

我按照https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-to-azure-button 中的描述创建了 URL。

我的结构如下:

  • Azure DevOps 组织 = MyOrganization 和项目是 myProject
  • repo 是myRepo,模板文件在分支myBranch,位于myFolder/myTemplate.json

最后,URL 看起来像
https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fdev.azure.com%2F{myOrganization}%2F{myProject}%2F_apis%2Fgit%2Frepositories%2F{myRepo}%2Fitems%3Fpath%3D%2F{myFolder}%2F{myTemplate}.json%26versionDescriptor.version%3D{myBranch}%26versionDescriptor.versionType%3Dbranch%26api-version%3D6.0

在浏览器中复制/粘贴此 URL 会返回上述错误...

我相信我的 JSON 文件是正确的(没有错误),因为它在以下两种情况下工作正常:

  • 如果使用与 Azure CLI 相同的 JSON 模板文件 (az deployment groupe create --template-file <myJSONtemplatefile> --parameters <myJSONparametersfile>
  • 如果在 Azure 门户中复制/粘贴 JSON 模板文件以在 https://portal.azure.com/#create/Microsoft.Template 进行自定义部署

我不明白Error parsing template... 的原因是什么

【问题讨论】:

    标签: azure arm-template


    【解决方案1】:

    找到了!
    问题是由于 AzDO 存储库是私有的,而不是公开的。
    这在 Microsoft 文档中已明确说明,但我错过了...(粗体字是我的)

    如果您使用 Git with Azure Repos 而不是 GitHub 存储库,您仍然可以使用“部署到 Azure”按钮。确保您的存储库是public。使用Items operation 获取模板。

    有了公开的 AzDO 存储库,一切都像魅力一样。

    【讨论】:

      猜你喜欢
      • 2021-10-11
      • 2022-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 2021-01-12
      • 1970-01-01
      相关资源
      最近更新 更多