Azure ARM Template - SQL Failover Group Error FailoverGroupCreateOrUpdateRequestReadOnlyPropertyModified

417 views Asked by At

Successfully deployed from ARM template the primary and secondary Azure SQL servers with expected failover groups. Deploying the ARM template on subsequent deployments is returning the following error message:

  "error": {
    "code": "FailoverGroupCreateOrUpdateRequestReadOnlyPropertyModified",
    "message": "The create or update failover group request body should not modify the read-only property 'location'."
  }
} undefined

We haven't made any changes to the primary or secondary server's location property as indicated in the error message.

Code snippet from the ARM template:

    {
      "comments": "Azure SQL Server Failover Group",
      "condition": "[parameters('isProduction')]",
      "type": "Microsoft.Sql/servers/failoverGroups",
      "apiVersion": "2015-05-01-preview",
      "name": "[concat(variables('sqlServerPrimaryName'), '/', variables('sqlServerFailoverName'))]",
      "location": "[parameters('sqlServerPrimaryLocation')]",
      "dependsOn": [
        "[resourceId('Microsoft.Sql/servers', variables('sqlServerPrimaryName'))]",
        "[resourceId('Microsoft.Sql/servers', variables('sqlServerSecondaryName'))]",
        "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('adminDbName'))]",
        "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('trxnDbName'))]",
        "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('dbaDbName'))]"
      ],
      "properties": {
        "readWriteEndpoint": {
          "failoverPolicy": "Automatic",
          "failoverWithDataLossGracePeriodMinutes": 60
        },
        "readOnlyEndpoint": {
          "failoverPolicy": "Disabled"
        },
        "partnerServers": [
          {
            "id": "[resourceId('Microsoft.Sql/servers', variables('sqlServerSecondaryName'))]"
          }
        ],
        "databases": [
          "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('adminDbName'))]",
          "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('trxnDbName'))]",
          "[resourceId('Microsoft.Sql/servers/databases', variables('sqlServerPrimaryName'), variables('dbaDbName'))]"
        ]
      }
    }
2

There are 2 answers

0
unknown On

As @Leon Yue's comment said:

Once the arm template is deployed, the failover group is created and exist. As the error said, location is read only. When we deploy it twice, even if you didn't set the location value, it will still update it, then cause the error.

You couldn't update location property when you deploy at the second time, and you need to move this property.

0
AstroBoy On

If possible then remove the location from the ARM template, As you have already given the sqlServerPrimaryName in failover group creation name, It takes the location of sqlServerPrimaryName.