Search code examples
azureazure-rm-template

Can't set max vCores through ARM template for SQL database


I'm trying to set the storage details of a SQL database through an ARM template. I want the maximum amount of vCores to be set to 2. However, the setting always defaults to 1. The rest of the properties work just fine.

I can't find anything on MSDN regarding a maxCapacity property, even though there is a minCapacity property. I found a few people on Stackoverflow talking about a maxCapacity property, but it doesn't seem to do anything.

Here's a snippet from my template:

"properties": {
    "collation": "SQL_Latin1_General_CP1_CI_AS",
    "maxSizeBytes": 268435456000,
    "catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
    "zoneRedundant": false,
    "readScale": "Disabled",
    "highAvailabilityReplicaCount": 0,
    "minCapacity": 0.5,
    "maxCapacity": 2,
    "autoPauseDelay": 60,
    "requestedBackupStorageRedundancy": "Geo",
    "isLedgerOn": "false",
    "availabilityZone": "NoPreference",
    "useFreeLimit": "false",
    "freeLimitExhaustionBehavior": "AutoPause",
    "maintenanceConfigurationId": "[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default')]"
  }

Here's a screenshot of the outcome


Solution

  • As I mentioned in the comments, it does not have a specific attribute to set the maximum number of vCores; instead, it can be provided in the sku capacity itself. After a workaround on your requirement, I found that increasing sku will be useful to set up more maximum vcores.

    Refer MSDoc to check resource limits, capacities using the vCore model & SO by @Cloudkollektiv for more related information.

    "sku": {
            "name": "Standard",
            "tier": "Standard",
            "Capacity": 2
          }
    

    By referring to the sample template from MSDoc to create a sql database, I tried to reproduce it in my environment and was able to deploy it successfully.

    {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "metadata": {
        "_generator": {
          "name": "bicep",
          "version": "0.12.40.16777",
          "templateHash": "16856611863128783179"
        }
      },
      "parameters": {
        "serverName": {
          "type": "string",
          "defaultValue": "[uniqueString('sql', resourceGroup().id)]",
          "metadata": {
            "description": ""
          }
        },
        "sqlDB": {
          "type": "string",
          "defaultValue": "",
          "metadata": {
            "description": ""
          }
        },
        "location": {
          "type": "string",
          "defaultValue": "[resourceGroup().location]",
          "metadata": {
            "description": ""
          }
        },
        "administratorLogin": {
          "type": "string",
          "metadata": {
            "description": ""
          }
        },
        "administratorLoginPassword": {
          "type": "secureString",
          "metadata": {
            "description": ""
          }
        }
      },
      "resources": [
        {
          "type": "Microsoft.Sql/servers",
          "apiVersion": "2022-05-01-preview",
          "name": "[parameters('server')]",
          "location": "[parameters('location')]",
          "properties": {
            "administratorLogin": "[parameters('administratorLogin')]",
            "administratorLoginPassword": "[parameters('administratorLoginPassword')]"
          }
        },
        {
          "type": "Microsoft.Sql/servers/databases",
          "apiVersion": "2022-05-01-preview",
          "name": "[format('{0}/{1}', parameters('server'), parameters('sqlDB'))]",
          "location": "[parameters('location')]",
          "properties": {
          "collation": "SQL_Latin1_General_CP1_CI_AS",
          "minCapacity": 0.5,
          "createMode": "Default"
       },
       "dependsOn": [
          "[resourceId('Microsoft.Sql/servers', parameters('server'))]"
       ],
          "sku": {
            "name": "Standard",
            "tier": "Standard",
            "Capacity": 2
          },
          "dependsOn": [
            "[resourceId('Microsoft.Sql/servers', parameters('server'))]"
          ]
        }
      ]
    }
    

    Output:

    enter image description here