【发布时间】: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