ARM Template for Multiple DB Creation with Advisors assigned to each DB

Brass Contributor

HI All,

 

Hi,

We are following the below Template file to create Multiple SQL Data base's with existing Elastic pool and SQL Server.
Now we are trying to add advisors for all Databases which are creating with the Template but it it throwing the below error.


There were errors in your deployment. Error code: InvalidTemplate.

##[error]Deployment template language expression evaluation failed: 'Unable to parse language expression 'concat(parameters('serverName')), '/', (parameters('databaseNames'), /DbParameterization')': expected token 'EndOfData' and actual 'Comma'.'. Please see https://aka.ms/arm-template-expressions for usage details.
##[warning]Validation errors were found in the Azure Resource Manager template. This can potentially cause template deployment to fail. Task failed while creating or updating the template deployment.. Please follow https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax
Starting Deployment.
Deployment name is Deploy-SQLDBwithElasticPool
There were errors in your deployment. Error code: InvalidTemplate.
##[error]Deployment template language expression evaluation failed: 'Unable to parse language expression 'concat(parameters('serverName')), '/', (parameters('databaseNames'), /DbParameterization')': expected token 'EndOfData' and actual 'Comma'.'. Please see https://aka.ms/arm-template-expressions for usage details.
##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment...
##[error]Task failed while creating or updating the template deployment.
Finishing: ARM Template deployment: SQL DB - ElasticPool

Template File:


{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serverName": {
"type": "String",
"metadata": {
"description": "Name for the SQL server"
}
},
"databaseNames": {
"type": "Array",
"metadata": {
"description": "Array of names for the SQL databases"
}
},
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "String",
"metadata": {
"description": "Location for server and DBs"
}
},
"serverNameExternalid": {
"type": "String"
},
"elasticPoolName": {
"type": "String"
},
"administratorLogin": {
"type": "string"
},
"administratorLoginPassword": {
"type": "securestring"
}
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2020-02-02-preview",
"name": "[parameters('serverName')]",
"location": "east us",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"version": "12.0"
}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2020-02-02-preview",
"name": "[concat(string(parameters('serverName')), '/', string(parameters('databaseNames')[copyIndex()]))]",
"location": "east us",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"sku": {
"name": "ElasticPool",
"tier": "Standard",
"capacity": 0
},
"kind": "v12.0,user",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": 268435456000,
"elasticPoolId": "[concat(parameters('serverNameExternalid'), '/elasticPools/', parameters('elasticPoolName'))]",
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"zoneRedundant": false,
"readScale": "Disabled",
"storageAccountType": "GRS"
},
"resources": [
{
"type": "securityAlertPolicies",
"apiVersion": "2020-02-02-preview",
"name": "default",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', parameters('serverName'), parameters('databaseNames')[copyIndex()])]"
],
"properties": {
"state": "Enabled"
}
},
{
"type": "Microsoft.Sql/servers/databases/advisors",
"apiVersion": "2014-04-01",
"name": "[concat(parameters('serverName'), '/', (parameters('databaseNames')[copyIndex('databaseCopy')].Name)], /DbParameterization')]", - This is the line where we are getitng the above mentioned error.
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', parameters('serverName'), parameters('databaseNames')[copyIndex()])]"
],
"properties": {
"autoExecuteValue": "Disabled"
}
}
],
"copy": {
"name": "databaseCopy",
"count": "[length(parameters('databaseNames'))]"
}
}
]
}


Regards,

Vignesh

2 Replies

@vigneshkrcegmailcom Looks like you have an extra /mission single quote in the line (here - parameters('databaseNames'), /DbParameterization')'.. please check and hope this will work.

@Nived1002V 

 

Hi,

 

No Luck. It is Throwing the same error.

 

Regards,

Vignesh