question

ChoudharyRavinaBT-9585 avatar image
0 Votes"
ChoudharyRavinaBT-9585 asked AnuragSharma-MSFT answered

Not able to add databse to exisitng server through ARM Tempate

Error getting : Deployment template validation failed: 'The template resource '*' for type 'Microsoft.Sql/servers/databases' at line '1' and column '2208' 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.'.

Template :

 {
   "name": "[parameters('databaseName')]",
   "type": "Microsoft.Sql/servers/databases",
   "location": "[resourceGroup().location]",
   "apiVersion": "2021-02-01-preview",
   "dependsOn": [
     "[parameters('sqlServerName')]"
   ],
   "properties": {
     "collation": "[parameters('collation')]",
     "edition": "[parameters('edition')]",
     "maxSizeBytes": "**********",
     "requestedServiceObjectiveName": "[parameters('requestedServiceObjectiveName')]",
     "zoneRedundant": false
   }
 },
azure-sql-database
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ChoudharyRavinaBT-9585, welcome to Microsoft Q&A forum.

Are you trying to create a new database for an existing Azure SQL Server? If yes, could you please provide the entire template as it would be easy to reproduce the issue faced by you?

0 Votes 0 ·
ChoudharyRavinaBT-9585 avatar image
0 Votes"
ChoudharyRavinaBT-9585 answered ChoudharyRavinaBT-9585 edited

@AnuragSharma-MSFT yes in existing SQL.Esiting sql template :

{
/
Create SQL
**/
"type": "Microsoft.Sql/servers",
"name": "[parameters('sqlServerName')]",
"apiVersion": "2021-02-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"administratorLogin": "[parameters('sqlAdministratorLogin')]",
"administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]",
"version": "[parameters('sqlServerVersion')]"
},
"resources": [
{
"type": "firewallrules",
"name": "AllowAllWindowsAzureIps",
"apiVersion": "2021-02-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
},
"dependsOn": [
"[parameters('sqlServerName')]"
]
}

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AnuragSharma-MSFT avatar image
0 Votes"
AnuragSharma-MSFT answered

Hi @ChoudharyRavinaBT-9585, thanks for your patience. Could you please try below template by replacing the placeholder values and let me know if it works:

 {
   "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
   "contentVersion": "1.0.0.0",
      
   "resources": [
     {
       "type": "Microsoft.Sql/servers",
       "apiVersion": "2020-02-02-preview",
       "name": "<yourexistingserver>",
       "location": "<location>",
       "properties": {
         "administratorLogin": "<username>",
         "administratorLoginPassword": "<password>"
       },
       "resources": [
         {
           "type": "databases",
           "apiVersion": "2020-08-01-preview",
           "name": "<newdbname>",
           "location": "<location>",
           "sku": {
             "name": "Standard",
             "tier": "Standard"
           },
           "dependsOn": [
             "[resourceId('Microsoft.Sql/servers', '<yourexistingserver>')]"
           ]
         }
       ]
     }
   ]
 }
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ChoudharyRavinaBT-9585, just wanted to check if you were able to run through this template.

0 Votes 0 ·