Why do I get the "This is not a valid template" error in my ARM template/JSON code?

John 101 Reputation points
2022-07-11T20:36:24.457+00:00

Hi there,

I am trying to create an ARM template for deploying an Azure SQL Database + Server. I am looking to use this ARM template in a Blueprint I am trying to setup. For some reason my template is not showing the amount of resource and gives me an error when trying to deploy it. I think there is something wrong with my JSON code. I included the code for the template below.

I also have a few other questions:

  • Is it possible and realistic to choose the maintenance window of the SQL Database via an ARM template?
  • How does deploying the Azure SQL Database with Azure Active Directory login only work? How do you login after deploying the ARM template?
  • How do I add a management lock to resources in my ARM template {
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
    "_generator": {
    "name": "bicep",
    "version": "0.5.6.12127",
    "templateHash": "17606057535442789180"
    }
    },
    "parameters": {
    "serverName": {
    "type": "string",
    "defaultValue": "[uniqueString('sql', resourceGroup().id)]",
    "metadata": {
    "description": "The name of the SQL logical server."
    }
    },
    "sqlDBName": {
    "type": "string",
    "defaultValue": "SampleDB",
    "metadata": {
    "description": "The name of the SQL Database."
    }
    },
    "location": {
    "type": "string",
    "defaultValue": "[resourceGroup().location]",
    "metadata": {
    "description": "Location for all resources."
    }
    },
    "administratorLogin": {
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The administrator username of the SQL logical server."
    }
    },
    "administratorLoginPassword": {
    "type": "secureString",
    "defaultValue": "",
    "metadata": {
    "description": "The administrator password of the SQL logical server."
    }
    },
    "administratorType":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The type of server administrator."
    }
    },
    "azureADOnlyAuthentication":{
    "type": "bool",
    "defaultValue": "",
    "metadata": {
    "description": "Azure Active Directory only Authentication enabled."
    }
    },
    "login":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "Login name of the server administrator."
    }
    },
    "principalType":{
    "type": "string",
    "defaultValue": "",
    "allowedValues": [
    "Application",
    "Group",
    "User"
    ],
    "metadata": {
    "description": "Principal Type of server administrator."
    }
    },
    "sid":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "SID (object ID) of the server administrator."
    }
    },
    "federatedClientId":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The Client id used for cross tenant CMK scenario"
    }
    },
    "keyId":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "A CMK URI of the key to use for encryption."
    }
    },
    "minimalTlsVersion":{
    "type": "string",
    "defaultValue": "",
    "allowedValues": [
    "1.0",
    "1.1",
    "1.2"
    ],
    "metadata": {
    "description": "Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'"
    }
    },
    "primaryUserAssignedIdentityId":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The resource id of a user assigned identity to be used by default."
    }
    },
    "publicNetworkAccess":{
    "type": "string",
    "defaultValue": "",
    "allowedValues": [
    "Disabled",
    "Enabled"
    ],
    "metadata": {
    "description": "Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'"
    }
    },
    "restrictOutboundNetworkAccess":{
    "type": "string",
    "defaultValue": "",
    "allowedValues": [
    "Disabled",
    "Enabled"
    ],
    "metadata": {
    "description": "Whether or not to restrict outbound network access for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled'"
    }
    },
    "version":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The version of the server."
    }
    },
    "catalogCollation":{
    "type": "string",
    "defaultValue": "SQL_Latin1_General_CP1_CI_AS",
    "allowedValues": [
    "SQL_Latin1_General_CP1_CI_AS",
    "DATABASE_DEFAULT"
    ],
    "metadata": {
    "description": "Collation of the metadata catalog."
    }
    },
    "highAvailabilityReplicaCount":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The number of secondary replicas associated with the database that are used to provide high availability."
    }
    },
    "isLedgerOn":{
    "type": "bool",
    "defaultValue": "false",
    "allowedValues": [
    "true",
    "false"
    ],
    "metadata": {
    "description": "Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created."
    }
    },
    "licenseType":{
    "type": "string",
    "defaultValue": "LicenseIncluded",
    "allowedValues": [
    "LicenseIncluded",
    "BasePrice"
    ],
    "metadata": {
    "description": "The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit."
    }
    },
    "maintenanceConfigurationId":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur."
    }
    },
    "maxSizeBytes":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The max size of the database expressed in bytes."
    }
    },
    "requestedBackupStorageRedundancy":{
    "type": "string",
    "defaultValue": "",
    "metadata": {
    "description": "The storage account type to be used to store backups for this database."
    }
    },
    "zoneRedundant":{
    "type": "bool",
    "defaultValue": "",
    "allowedValues": [
    "true",
    "false"
    ],
    "metadata": {
    "description": "Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones."
    }
    },
    "resources": [
    {
    "type": "Microsoft.Sql/servers",
    "apiVersion": "2021-08-01-preview",
    "name": "[parameters('serverName')]",
    "location": "[parameters('location')]",
    "properties": {
    "administratorLogin": "[parameters('administratorLogin')]",
    "administratorLoginPassword": "[parameters('administratorLoginPassword')]",
    "administrators": {
    "administratorType": "ActiveDirectory",
    "azureADOnlyAuthentication": "bool",
    "azureADlogin": "string",
    "principalType": "string",
    "sid": "string",
    "tenantId": "string"
    },
    "federatedClientId": "string",
    "keyId": "string",
    "minimalTlsVersion": "string",
    "primaryUserAssignedIdentityId": "string",
    "publicNetworkAccess": "string",
    "restrictOutboundNetworkAccess": "string",
    "version": "string"
    }
    },
    {
    "type": "Microsoft.Sql/servers/databases",
    "apiVersion": "2021-08-01-preview",
    "name": "[format('{0}/{1}', parameters('serverName'), parameters('sqlDBName'))]",
    "location": "[parameters('location')]",
    "sku": {
    "name": "Standard",
    "tier": "Standard"
    },
    "properties": {
    "catalogCollation": "string",
    "highAvailabilityReplicaCount": "int",
    "isLedgerOn": "bool",
    "licenseType": "string",
    "maintenanceConfigurationId": "string",
    "maxSizeBytes": "int",
    "requestedBackupStorageRedundancy": "string",
    "zoneRedundant": "bool"
    },
    "dependsOn": [
    "[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
    ]
    }
    ]
    }
    }
Azure Blueprints
Azure Blueprints
An Azure service that provides templates for quick, repeatable creation of fully governed cloud subscriptions.
70 questions
Azure SQL Database
0 comments No comments
{count} vote

Accepted answer
  1. Alberto Morillo 32,886 Reputation points MVP
    2022-07-11T22:28:41.98+00:00

    Please try to use Visual Studio Code and the Bicep Extension or the ARM extension to validate the invalid template and help you troubleshoot the issue. Please see here how the BICEP template starts with the word "resource".

    About choosing a maintenance window for Azure SQL using ARM templates, that is not possible. You can only use the following options to configure that: Azure portal, PowerShell, Azure CLI, and REST API.

    Please read this documentation to better understand what actions are needed before and after enable the AAD authentication only option. On the same documentation you will find an ARM template example.

    On this documentation you will find how to configure a lock using ARM template or BICEP file.


0 additional answers

Sort by: Most helpful