Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.08k stars 16.13k forks source link

The template resource '[concat(parameters('Vault_name'), '/', parameters('secretsObject').secrets[copyInd ex()].secretName)]' at line '73' and column '9' is not valid: The language expression property 'secrets' doesn't exist, available properties are 'CliXml' #7673

Open LALITAMITTAL18 opened 4 years ago

LALITAMITTAL18 commented 4 years ago

201-key-vault-secret-create [(https://github.com/Azure/azure-quickstart-templates/tree/master/201-key-vault-secret-create)

Below is my Parameters.Json file: { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "Vault_name":"KVCheck", "secretsObject": { "value": { "secrets": [ { "secretName": "Test1", "secretValue": "Sample Value" }, { "secretName": "Test2", "secretValue": "Sample Value" }
] } } } }

and here is my Template :

{

"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "Vault_name": { "defaultValue": "APIMSPOConnectorKeyVault", "type": "string" }

"secretsObject": {
  "type": "secureObject",
  "metadata": {
    "description": "Specifies all secrets {\"secretName\":\"\",\"secretValue\":\"\"} wrapped in a secure object."
  }
}

}, "variables": {}, "resources": [ { "type": "Microsoft.KeyVault/vaults", "apiVersion": "2016-10-01", "name": "[parameters('Vault_name')]", "location": "[resourceGroup().location]", "properties": { "sku": { "family": "A", "name": "Standard" }, "tenantId": "[subscription().tenantId]", "accessPolicies": [ ], "enabledForDeployment": true, "enabledForDiskEncryption": false, "enabledForTemplateDeployment": true, "enableSoftDelete": true } }, { "type": "Microsoft.KeyVault/vaults/secrets", "name": "[concat(parameters('Vault_name'), '/', parameters('secretsObject').secrets[copyIndex()].secretName)]", "apiVersion": "2018-02-14", "dependsOn": [ "[concat('Microsoft.KeyVault/vaults/', parameters('Vault_name'))]" ], "copy": { "name": "secretsCopy", "count": "[length(parameters('secretsObject').secrets)]" }, "properties": { "value": "[parameters('secretsObject').secrets[copyIndex()].secretValue]" } } ] } and its not able to recognize the object.

MCKLMT commented 4 years ago

According to this post, you should wrap your secrets in a json object. The correct syntax seems to be:

"secrets": {
    "value": {
        "array": [
            {
                "secretName": "exampleSecret1",
                "secretValue": "secretVaule1"
            },
            {
                "secretName": "exampleSecret2",
                "secretValue": "secretValue2"
            }
        ]
    }
}

@LALITAMITTAL18 Can you check on your side?