I am trying to deploy Redis with the help of the ARM template listed below - and then return its primary key (the secret string available in Azure portal for Redis under "Access keys" -> "Primary"):
However I get the error message from my pipeline "AzureResourceManagerTemplateDeployment@3" task:
[error]Unable to evaluate template outputs: 'RedisCachePassword'. Please see error details and deployment operations. Please see https://aka.ms/arm-debug for usage details.
[error]Details:
[error]DeploymentOutputEvaluationFailed: The template output 'RedisCachePassword' is not valid: The language expression property 'primaryKey' can't be evaluated..
What is please wrong with my ARM template below? And how to be able to find the correct names in such cases?
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "redisCacheName": {
            "defaultValue": "my-redis",
            "type": "String"
        }
    },
    "variables": {
        "resourceName": "[concat(resourceGroup().name, '-', parameters('redisCacheName'))]"
    },
    "outputs": {
      "RedisCacheEndpoint": {
        "type": "string",
        "value": "[concat(reference(variables('resourceName')).hostName, ':', reference(variables('resourceName')).sslPort)]"
      },
      "RedisCachePassword": {
        "type": "string",
        "value": "[reference(variables('resourceName')).accessKeys.primaryKey]"
      }
    },
    "resources": [
        {
            "type": "Microsoft.Cache/Redis",
            "apiVersion": "2019-07-01",
            "name": "[variables('resourceName')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "sku": {
                    "name": "Basic",
                    "family": "C",
                    "capacity": 1
                },
                "enableNonSslPort": false
            }
        }
    ]
}
Why does not [reference(variables('resourceName')).accessKeys.primaryKey] work?


