我正在尝试创建一个基础架构,以使用数据同步将 Azure 数据库与本地数据库同步。
我的下一步是创建一个“数据同步组”,但我不知道该怎么做。
是否可以使用 Terraform 创建此基础设施?
最佳答案
目前, Data Sync Group 可以通过Portal或ARM模板创建。如果您想使用 Terraform,则可以使用 azurerm_resource_group_template_deployment
,如下所示:
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
}
引用:
ARM 模板 Data Sync Group
和 Data Sync Group Members
azurerm_resource_group_template_deployment | Resources | hashicorp/azurerm | Terraform Registry
关于azure - 创建Sql同步组可以吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70540997/