Search code examples
azureazure-devopsazure-pipelinesazure-sql-databasedevops

Azure Pipeline Data Sync


We have some databases(10 databses) in dev and test environments on Azure SQL. We would like to be able to sync the data between environments using the azure pipeline.

The Schema changes happen automagically with entity framework migrations which is fine.

For syncing data, We've created a data compare in visual studio that we use to sync the data on demand. Now we would like to automate this process(syncing data).

Is there an existing task that we can add to the pipeline to run this data compare and subsequent sync?


Solution

  • You can do that with SQL Data Sync for Azure.

    And what it does:

    SQL Data Sync is a service built on Azure SQL Database that lets you synchronize the data you select bi-directionally across multiple databases, both on-premises and in the cloud.

    Fir you need to:

    • create sync group - on your prod database
    • use sync members - here you will use your test database
    • than configure group sync

    What is cool about that you can select what particularly should be synced:

    enter image description here

    You can then trigger that from azure pipelines calling

    Start-AzSqlSyncGroupSync -ResourceGroupName $resourceGroupName -ServerName $serverName -DatabaseName $databaseName -SyncGroupName $syncGroupName
    

    from Azure PowerShell task. If you define cron schedule you will get you data up to date.