Создание вторичной гео-базы данных выполняется с помощью API создания базы данных.Ниже приведен пример API-интерфейса REST:
{
"location": "southeastasia",
"sku": {
"name": "S0",
"tier": "Standard"
},
"properties": {
"createMode": "Secondary",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"
}
}
(с https://docs.microsoft.com/en-us/rest/api/sql/databases/createorupdate#creates_a_database_as_an_on-line_secondary.)
Доступно в Python SDK (azure-mgmt-sql), напримерэто:
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.sql import SqlManagementClient
from azure.mgmt.sql.models import CreateMode
RESOURCE_GROUP = 'YOUR_RESOURCE_GROUP_NAME'
LOCATION = 'eastus' # example Azure availability zone, should match resource group
SQL_SERVER = 'yourvirtualsqlserver'
SQL_DB = 'YOUR_SQLDB_NAME'
sql_client = get_client_from_cli_profile(SqlManagementClient)
# Create a SQL database in the Basic tier
database = sql_client.databases.create_or_update(
RESOURCE_GROUP,
SQL_SERVER,
SQL_DB,
{
'location': LOCATION,
'create_mode': CreateMode.secondary.value,
'source_database_id': '/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb'
}
)