【问题标题】:Azure ARM template GEN_PASSWORD placeholder not workingAzure ARM 模板 GEN_PASSWORD 占位符不起作用
【发布时间】:2020-06-30 11:07:30
【问题描述】:

我正在尝试使用 ARM 模板将简单资源组部署到 Azure。它由具有公共 IP 和 nsg 的单个虚拟机组成,允许通过 SSH 访问它。为了确保访问安全,我正在为 VM 设置管理员用户名和密码,这些用户名和密码通过参数 json 传递给模板。 VM 定义如下所示:

{
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2018-10-01",
      "name": "[variables('vmName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "Standard_D2s_v3"
        },
        "osProfile": {
          "computerName": "[variables('vmName')]",
          "adminUsername": "[parameters('adminUsername')]",
          "adminPassword": "[parameters('adminPassword')]",
          "linuxConfiguration": {
            "disablePasswordAuthentication": false
          }
        },
     // ...
     },
// ...
}

根据Azure quickstart templates repository 生成密码,我可以使用 GEN-PASSWORD 占位符和 GEN-UNIQUE 来获取唯一的字母数字字符串。这就是为什么我的参数 json 看起来像这样:


    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        // ...
        "adminUsername": {
            "value": "GEN_UNIQUE"
        },
        "adminPassword": {
            "value": "GEN_PASSWORD"
        }
    }
}

但是,每当我尝试部署它(通过 Azure DevOps Pipeline)时,我都会收到密码无效的错误:

2020-06-29T21:27:40.5401781Z ##[error]At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.
2020-06-29T21:27:40.5416217Z ##[error]Details:
2020-06-29T21:27:40.5419655Z ##[error]InvalidParameter: The supplied password must be between 6-72 characters long and must satisfy at least 3 of password complexity requirements from the following:
1) Contains an uppercase character
2) Contains a lowercase character
3) Contains a numeric digit
4) Contains a special character
5) Control characters are not allowed

有人可以帮忙吗?我试图找到有关这些占位符的更多信息,但我上面链接的 Azure GitHub 存储库似乎是唯一的来源。

【问题讨论】:

    标签: azure azure-devops arm-template


    【解决方案1】:

    GEN* 值为 special placeholders,仅在 Azure 资源管理器快速入门模板存储库及其自动模板验证的上下文中有效。

    恐怕您不能在自己的自定义 Azure DevOps 管道中使用这些占位符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 2015-05-10
      • 2014-03-04
      • 2015-03-24
      • 2017-06-29
      相关资源
      最近更新 更多