Resolve errors for parent resources

This article describes the errors you may encounter when deploying a resource that is dependent on a parent resource.

Symptom

When deploying a resource that is a child to another resource, you may receive the following error:

Code=ParentResourceNotFound;
Message=Can not perform requested operation on nested resource. Parent resource 'exampleserver' not found."

Cause

When one resource is a child to another resource, the parent resource must exist before creating the child resource. The name of the child resource includes the parent name. For example, a SQL Database might be defined as:

{
  "type": "Microsoft.Sql/servers/databases",
  "name": "[concat(variables('databaseServerName'), '/', parameters('databaseName'))]",
  ...

But, if you do not specify a dependency on the server, the database deployment might start before the server has deployed.

Solution

To resolve this error, include a dependency.

"dependsOn": [
    "[variables('databaseServerName')]"
]

For more information, see Define the order for deploying resources in Azure Resource Manager templates.