gpt4 book ai didi

azure - 将凭证从arm模板传递给DSC脚本

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

我正在尝试从 ARM 模板部署具有 DSC 扩展的虚拟机。根据各种消息来源,甚至this SO question,我正在按照正确的方法将凭证对象传递给我的脚本:

"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.19",
"autoUpgradeMinorVersion": true,
"settings": {
"modulesUrl": "[concat(parameters('_artifactsLocation'), '/', variables('ConfigureRSArchiveFolder'), '/', variables('ConfigureRSArchiveFileName'), '/', parameters('_artifactsLocationSasToken'))]",
"configurationFunction": "[variables('rsConfigurationConfigurationFunction')]",
"properties": {
"SQLSAAdminAuthCreds": {
"UserName": "[parameters('SSRSvmAdminUsername')]",
"Password": "PrivateSettingsRef:SAPassword"
}
}
},
"protectedSettings": {
"Items": {
"SAPassword": "[parameters('SSRSvmAdminPassword')]"
}
}
}

但是,当我部署它时,我收到此错误消息:

Error message: "The DSC Extension received an incorrect input: The password element of 
argument 'SQLSAAdminAuthCreds' to configuration 'PrepareSSRSServer' does not
match the required format. It should be as follows
{
"UserName" : "MyUserName",
"Password" : "PrivateSettingsRef:MyPassword"
}.
Please correct the input and retry executing the extension.".

据我所知,我的格式是正确的。我缺少什么?谢谢

最佳答案

函数似乎尝试使用导致问题的参数。因此,请尝试检查 ps1 文件中使用 SQLSAAdminAuthCreds 的函数。我无法重现您提到的问题。我做了一个demo,以下是我的详细步骤。

1.准备一个ps1文件,我从article获取演示代码

configuration Main
{
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullorEmpty()]
[PSCredential]
$SQLSAAdminAuthCreds
)
Node localhost {
User LocalUserAccount
{
Username = $SQLSAAdminAuthCreds.UserName
Password = $SQLSAAdminAuthCreds
Disabled = $false
Ensure = "Present"
FullName = "Local User Account"
Description = "Local User Account"
PasswordNeverExpires = $true
}
}
}

2.压缩ps1文件

3.从Azure门户下载ARM模板和参数。

enter image description here

enter image description here enter image description here enter image description here

4.编辑模板和参数文件

enter image description here

  • 尝试使用 VS 或 Powershell 部署 ARM 模板

  • 从 Azure 门户或输出中检查。

  • enter image description here

    关于azure - 将凭证从arm模板传递给DSC脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42514654/

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