Skip to content

New-AzureRmResourceGroupDeployment with KeyVault reference in TemplateParameterObject #3318

@kfrajtak

Description

@kfrajtak

Hi,

I have an Azure deployment template that creates a VM and joins it to a domain. The password (domainJoinUserPassword) of the user that has the rights to add a machine to a domain is stored in a key vault. The deployment works perfectly fine when parameters are defined in a JSON file (the key vault reference included). New-AzureRmResourceGroupDeployment commandlet is invoked with TemplateParameterFile parameter.

However, when I have modified the script to use hash table with parameter to be provided as a value of
TemplateParameterObject parameter, I am getting the following error

The provided value for the template parameter 'domainJoinUserPassword' at line '71' and column '36' is not valid.'

The hash table looks like this:

$parameters = @{
  ...
  domainJoinUserPassword = @{
    reference =  @{
      keyVault = @{
        id =  "/subscriptions/id/resourceGroups/Infra/providers/Microsoft.KeyVault/vaults/VaultName"
      }
      secretName = "MySecret"
    }
  }

How can I reference the key vault secret in the hash table? Or is this not the right approach and I should stick with the JSON file?

Thanks, Karel

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions