【问题标题】:Passing credentials to DSC script from arm template从 arm 模板向 DSC 脚本传递凭据
【发布时间】:2017-02-28 17:01:57
【问题描述】:

我正在尝试从 ARM 模板部署具有 DSC 扩展的 VM。根据各种消息来源,甚至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.".

据我所知,我的格式是正确的。我错过了什么?谢谢

【问题讨论】:

  • 你试过硬编码吗?我看不出你的模板有什么问题
  • 硬编码密码?嗯,我试试,但是不能用……
  • 不幸的是,它总是返回相同的错误消息。我尝试更改 apiVersion,将“属性”更改为“configurationArguments”,将凭据更改为完全在 protectedSettings 中传递。它总是给出相同的错误信息...
  • 您是否尝试过使用具有相同功能的 github 快速入门模板,看看它们是否适合您?

标签: azure azure-resource-manager dsc arm-template


【解决方案1】:

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

1.准备一个ps1文件,我从article得到demo代码

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 模板和参数。

4.编辑模板和参数文件

  1. 尝试用VS或Powershell部署ARM模板

  2. 从 Azure 门户或输出中检查。

【讨论】:

  • 不太确定我的模板出了什么问题,但感谢您的回答。它一定是某种形式的畸形,因为它现在可以工作了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-15
  • 2019-09-12
相关资源
最近更新 更多