1
votes

I'm trying to configure an Azure SQL database for multi-region replication and I am having a hard time to reference the source database in my ARM template.

  "outputs": {
"primarySQL": {
  "type": "object",
  "value": "[reference(concat(parameters('serverNamePrimary')))]"
},
"primaryDB": {
  "type": "object",
  "value": "[reference(concat('Microsoft.Sql/servers/databases','/',parameters('serverNamePrimary'),'/',parameters('databaseName')))]"
}
}

The reference to the SQL Server works fine. The reference to the database doesn't work.

How do I get the resourceId from a database that I am deploying in the same template? I need to use the db's resourceId later then to reference that as the sourceDatabaseId as mentioned here: https://docs.microsoft.com/en-us/azure/templates/microsoft.sql/servers/databases

Cheers David

1

1 Answers

1
votes

Never mind... seems you can't reference this in the Outputs section... but adding this here to the secondary DB resource works:

"sourceDatabaseId": "[resourceId('Microsoft.Sql/servers/databases', parameters('serverNamePrimary'), parameters('databaseName'))]",