I have an application which consists of 2 web applications with a SQL database for each. The plan is to put each web application and its DB into a separate resource group. The shared SQL Server will be in its own resource group.
How can I reference the shared SQL Server in the Azure Resource Manager template of a web application?
I already tried the following:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": { },
"resources": [
{
"name": "Microsoft.Sql/servers/sqlserver-dev/databases/app1db",
"type": "Microsoft.Sql/servers/databases",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ ],
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "Basic"
}
}
]
}
But this approach gives me the error:
Deployment template validation failed: 'The template resource 'Microsoft.Sql/servers/sqlserver-dev/databases/app1db' for type 'Microsoft.Sql/servers/databases' at line '1' and column '202' has incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name. Please see https://aka.ms/arm-template/#resources for usage details.'.
When I use the resourceId of the SQL server:
/subscriptions/{GUID}/resourceGroups/sql-server-group/providers/Microsoft.Sql/servers/sqlserver-dev/databases/app1db
I get the same error.
Any ideas how to establish the cross-resource-group link?