Within an ARM template, there are times when a resource identifier is used multiple times in resource configurations. Instead of using the same code for generating a resource identifier multiple times, it is a good practice to generate them once within the variables section and use the variable in the resource configuration.
The databaseIdentifier and subnetIdentifier variables can be used at multiple places within the ARM template. The value is generated once and used multiple times. It also helps with maintenance, since making changes at a single place can affect operations in multiple places:
"variables": {
"virtualNetworkName": "testvirtualNetwork",
"subnetName": "testSubnetName",
"databaseIdentifier": "[resourceId('Microsoft.SQL/servers/databases...