【发布时间】:2020-06-13 16:01:56
【问题描述】:
我正在尝试使用 ARM 模板通过 Powershell 部署虚拟机。
我想使用模板参数将 SSH 公钥传递到模板中。
模板文件中的参数定义如下:
"parameters": {
"sshPublicKey": {
"type": "string"
}
},
这是我从文件加载公钥并将其添加为模板参数的 powershell 脚本。
$publicKey = (Get-Content .\keys\id_rsa.pub)
"Public Key is string of length {0}" -f $publicKey.Length
$parametersObject = @{"sshPublicKey" = $publicKey }
"Running the Deployment now"
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile .\template.json -TemplateParameterObject $parametersObject
我收到以下令人沮丧的错误:
New-AzResourceGroupDeployment:上午 9:02:09 - 错误: 代码=无效模板; Message=部署模板验证失败: '模板参数 JToken 类型无效。应为“字符串,Uri”。 实际的“对象”。请参见 https://aka.ms/resource-manager-parameter-files 了解使用详情。'。 在 C:\users\sheph\Documents\GitHub\aspnet-core-linux-exercise\setup-ubuntu-nginx\deploy.ps1:20 字符:1 + New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName - ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:未指定:(:) [New-AzResourceGroupDeployment],异常 + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
起初我认为这是字符串长度的问题。 (密钥长度为 402 个字符)。但是,如果我用 402 个连续的“A”字符替换它,我不会收到错误。
我有另一个使用模板参数文件而不是模板参数对象的示例,这也可以。
有什么办法可以让它工作吗?
【问题讨论】:
标签: azure azure-powershell azure-deployment azure-template