Home > Net >  Create a Sql Synchronization Group is it possible?
Create a Sql Synchronization Group is it possible?

Time:01-04

I am trying to create an infrastructure to synchronize an azure database with an on-premises database using Data Sync.

My next step is to create a “Data Sync Group”, but I can’t figure out how to do it.

Is it possible to create this infrastructure with Terraform?

CodePudding user response:

Currently , Data Sync Group can be created through Portal or ARM template. If you want to use Terraform then you can use the azurerm_resource_group_template_deployment like below :

locals {
  syncdatabaseId = "id"
}

resource "azurerm_resource_group_template_deployment" "example" {
  name                = "example-deploy"
  resource_group_name = "example-group"
  deployment_mode     = "Incremental"
  parameters_content = jsonencode({
    "syncdatabaseId" = {
      value = local.syncdatabaseId
    }
  })
  template_content = <<TEMPLATE
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "syncdatabaseId": {
            "type": "string",
            "metadata": {
                "description": "id of the database"
            }
        }
    },
    "variables": {},
    "resources": [
        {
  "type": "Microsoft.Sql/servers/databases/syncGroups",
  "apiVersion": "2021-05-01-preview",
  "name": "string",
  "sku": {
    "capacity": "int",
    "family": "string",
    "name": "string",
    "size": "string",
    "tier": "string"
  },
  "properties": {
    "conflictLoggingRetentionInDays": "int",
    "conflictResolutionPolicy": "string",
    "enableConflictLogging": "bool",
    "hubDatabasePassword": "string",
    "hubDatabaseUserName": "string",
    "interval": "int",
    "schema": {
      "masterSyncMemberName": "string",
      "tables": [
        {
          "columns": [
            {
              "dataSize": "string",
              "dataType": "string",
              "quotedName": "string"
            }
          ],
          "quotedName": "string"
        }
      ]
    },
    "syncDatabaseId": "[parameters('syncdatabaseId')]",
    "usePrivateLinkConnection": "bool"
  }
}
]
}
TEMPLATE

  // NOTE: whilst we show an inline template here, we recommend
  // sourcing this from a file for readability/editor support
}

Reference:

ARM Template Data Sync Group and Data Sync Group Members

azurerm_resource_group_template_deployment | Resources | hashicorp/azurerm | Terraform Registry

  • Related