title: Can a "Microsoft.Resources/deployments" dependsOn another "Microsoft.Resources/deployments" in Azure ARM Templates?
body: <p>I want to 1st deploy a resource group, next deploy a bunch of resources (say a storage account and a keyvault), and finally create some Key Vault secrets (secret with the key to the storage account created in previous step).</p>
  
  <p>this is how i define my resources</p>
  
  <pre><code>"resources": [
      {
          "type": "Microsoft.Resources/resourceGroups",
          "apiVersion": "2018-05-01",
          "location": "[parameters('RgLocation')]",
          "name": "[variables('RgName')]",
          "properties": {},
          "tags": "[variables('ResourceTags')]"
      },
      {
          "type": "Microsoft.Resources/deployments",
          "apiVersion": "2018-05-01",
          "name": "resourcesDeployment",
          "resourceGroup": "[variables('RgName')]",
          "dependsOn": [
              "[resourceId('Microsoft.Resources/resourceGroups', variables('RgName'))]"
          ],
          "properties": {
              ...
          }
      },
      {
          "type": "Microsoft.Resources/deployments",
          "apiVersion": "2018-05-01",
          "name": "secretsDeployment",
          "resourceGroup": "[variables('RgName')]",
          "dependsOn": [
              "[resourceId('Microsoft.Resources/deployments', 'resourcesDeployment')]"
          ],
          "properties": {
             ...                
          }
      }
  ]
  </code></pre>
  
  <p>the resourcesDeployment "dependsOn" the resource group, which works perfectly/as expected.</p>
  
  <p>the secretsDeployment "dependsOn" resourcesDeployment and this is the part that fails. I'm getting this error:</p>
  
  <blockquote>
    <p>Deployment template validation failed: 'The resource 'Microsoft.Resources/deployments/resourcesDeployment' is not defined in
    the template.</p>
  </blockquote>
  
  <p>How do I ensure that these deployments happen in order.</p>
  
  <p>Any help is much appreciated</p>