The other answer in this thread is misleading, to say the least.
It does not matter which route you take to actually supply the value to the dependsOn (or any other property) of the template. Hell, you can just put a string there
"dependsOn" [
"/subscription/GUID/resourceGroups/rgName/provider/providerName/resource/resourceName"
]
obviously, this is a bad idea, but it illustrated the point. you just need to return a VALID resource identifier, you can construct it in any way (or you can pass it in as a variable when provisioning with a script).
Also, sometimes resourceId can't work when you are using nested resource, so you need to concatenate 3 variables, in that case concat can help.
And nothing prevents you from nesting one inside the other:
"[concat(resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'), 'SOME TEXT'))]
TLDR you can use any way you like to return a valid resource identifier.
ps: example of a "broken" resourceId that would work normally:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "nestedTemplate",
"resourceGroup": "xxx",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-06-01",
"name": "egw4y35hthrh35h24tz1",
"location": "eastus",
"sku": {
"name": "Standard_LRS"
},
"tags": {
"test": "[resourceId('Microsoft.Storage/storageAccounts', 'test')]"
},
"kind": "Storage",
"properties": {}
}
]
}
}
}
]
}
this has to be a subscription level deployment