0
votes

I am trying to deploy Redis Cache using an ARM Template but it keeps failing with the following error:

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"LinkedInvalidPropertyId\",\r\n \"message\": \"Property id 'GET-PREREQ-existingDiagnosticsStorageAccountId' at path 'properties.storageAccountId' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'.\"\r\n }\r\n}"}]}

Scoured resources online but I'm unable to figure out what exactly is going wrong. The Redis Cache resource does get created but the deployment isn't completely successful. The following seems to be failing: https://imgur.com/a/xsp0OqL https://imgur.com/a/mpBBIAm

azuredeployredis.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "redisCacheName": {
      "type": "string",
      "defaultValue": "defaultRedisCacheName",
      "metadata": {
        "description": "The name of the Azure Redis Cache to create."
      }
    },
    "redisCacheSKU": {
      "type": "string",
      "allowedValues": [
        "Basic",
        "Standard",
        "Premium"
      ],
      "defaultValue": "Standard",
      "metadata": {
        "description": "The pricing tier of the new Azure Redis Cache."
      }
    },
    "redisCacheFamily": {
      "type": "string",
      "defaultValue": "C",
      "metadata": {
        "description": "The family for the sku."
      },
      "allowedValues": [
        "C",
        "P"
      ]
    },
    "redisCacheCapacity": {
      "type": "int",
      "allowedValues": [
        0,
        1,
        2,
        3,
        4,
        5,
        6
      ],
      "defaultValue": 1,
      "metadata": {
        "description": "The size of the new Azure Redis Cache instance. "
      }
    },
    "enableNonSslPort": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "A boolean value that indicates whether to allow access via non-SSL ports."
      }
    },
    "diagnosticsEnabled": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "A value that indicates whether diagnostics should be saved to the specified storage account."
      }
    },
    "existingDiagnosticsStorageAccountId": {
      "type": "string",
      "metadata": {
        "description": "Existing storage account for diagnostics."
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "[parameters('redisCacheName')]",
      "type": "Microsoft.Cache/Redis",
      "location": "[resourceGroup().location]",
      "properties": {
        "enableNonSslPort": "[parameters('enableNonSslPort')]",
        "sku": {
          "capacity": "[parameters('redisCacheCapacity')]",
          "family": "[parameters('redisCacheFamily')]",
          "name": "[parameters('redisCacheSKU')]"
        }
      },
      "resources": [
        {
          "apiVersion": "2017-05-01-preview",
          "type": "Microsoft.Cache/redis/providers/diagnosticsettings",
          "name": "[concat(parameters('redisCacheName'), '/Microsoft.Insights/', parameters('redisCacheName'))]",
          "location": "[resourceGroup().location]",
          "dependsOn": [
            "[concat('Microsoft.Cache/Redis/', parameters('redisCacheName'))]"
          ],
          "properties": {
            "storageAccountId": "[parameters('existingDiagnosticsStorageAccountId')]",
            "metrics": [
              {
                "timeGrain": "AllMetrics",
                "enabled": "[parameters('diagnosticsEnabled')]",
                "retentionPolicy": {
                  "days": 90,
                  "enabled": "[parameters('diagnosticsEnabled')]"
                }
              }
            ]
          }
        }
      ]
    }
  ]
}

azuredeployredis.parameters.json:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
  "parameters": {
    "redisCacheName": {
      "value": "xyz-redis-cache"
    },
    "existingDiagnosticsStorageAccountId": {
      "value": "GET-PREREQ-existingDiagnosticsStorageAccountId"
    }
  }
}

1
As the error message indicates the storageAccountId needs to be a complete resource id of the storage account instead of GET-PREREQ-existingDiagnosticsStorageAccountId as indicated by your params filebit

1 Answers

1
votes

I mean, the error clearly says you need to pass in resourceId, not resource name to the properties.storageAccountId. it should look like this:

/subscriptions/guid/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storagename

you can use resourceId() function to calculate that:

resourceId('subscriptionId', 'resourceGroupname', 'Microsoft.Storage/storageAccounts', 'storageaccountname')

subscriptionid and resourcegroupname are only needed if storage account is in different subscription and\or resource group