gpt4 book ai didi

azure - 从 Powershell 使用 Azure json 部署模板时如何以交互方式询问管理员密码?

转载 作者:行者123 更新时间:2023-12-03 01:40:20 26 4
gpt4 key购买 nike

上下文

我已下载正在运行的 Azure Windows VM 的自动化脚本。我决定使用 Powershell 脚本来自动化部署。

json 架构的 VM 部分需要“adminPassword”。它丢失了,所以我添加了它,并在模板和参数文件中都引入了参数:

模板.json

"parameters": {
"adminPassword": { "type": "securestring" },
...
...
"resources": [
...
...
"osProfile": {
"computerName": "[parameters('virtualMachines_name')]",
"adminUsername": "myname",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
},
"secrets": [],
"allowExtensionOperations": true
},

parameters.json

"parameters": {
"adminPassword": { "type": "securestring" }

不错的尝试,但不知何故,我内心深处知道它不会做任何事情,我的意思是不会以交互方式询问任何内容。缺少一个或多个步骤...但我卡在这里...

在“官方”MS 文档中,作者只是将明文密码放入parameters.json 中,这是相当令人不安的。请参阅:placing the clear password into the paramters.json?

最佳答案

我刚刚测试了它,它的工作原理就像这样,你可以更新你的 azure powershell,它可能已经严重过时了。

参数:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"test": {
"value": "1"
}
}
}

模板:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"test": {
"type": "string"
},
"testo": {
"type": "string"
}
},
"resources": []
}

powershell:

New-AzResourceGroupDeployment -ResourceGroupName NetworkWatcherRG -TemplateUri 'https://paste.ee/d/S2wJm/0' -TemplateParameterUri 'https://paste.ee/d/8rW6k/0'

它会提示您缺少参数。如果您使用 TemplateParameterFile

也会发生同样的情况

关于azure - 从 Powershell 使用 Azure json 部署模板时如何以交互方式询问管理员密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54347958/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com