SqlBulkSyncFunction 2026.12.3.572
dotnet add package SqlBulkSyncFunction --version 2026.12.3.572
NuGet\Install-Package SqlBulkSyncFunction -Version 2026.12.3.572
<PackageReference Include="SqlBulkSyncFunction" Version="2026.12.3.572" />
<PackageVersion Include="SqlBulkSyncFunction" Version="2026.12.3.572" />
<PackageReference Include="SqlBulkSyncFunction" />
paket add SqlBulkSyncFunction --version 2026.12.3.572
#r "nuget: SqlBulkSyncFunction, 2026.12.3.572"
#:package SqlBulkSyncFunction@2026.12.3.572
#addin nuget:?package=SqlBulkSyncFunction&version=2026.12.3.572
#tool nuget:?package=SqlBulkSyncFunction&version=2026.12.3.572
SqlBulkSyncFunction 
Azure Function version of WCOMAB/SqlBulkSync tool, a lightweight, performant non-intrusive SQL Server data sync service.
It doesn’t use any triggers or events, but instead uses SQL Server change tracking. Supported databases are SQL Server 2022 (16.x) or newer, Azure SQL Database and Azure SQL Managed Instance. The service was developed primary for syncing on premise SQL server data to Azure in an efficient way, where only the changes are transferred. But it will also work just fine between on-premise/cloud instances too.
Prerequisites
- SQL Server 2022 (16.x) or newer, Azure SQL Database, or Azure SQL Managed Instance (source and target). Older SQL Server versions are not supported.
- .NET 10 SDK - https://dotnet.microsoft.com/en-us/download
- Azure Functions Core Tools version 4.0, or a later version - https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#v2
- Azure CLI version 2.50, or a later version - https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
- IDE
- Visual Studio 2026 or a later version
- VS Code 1.90, or a later version
Configuration
The function is configured through Azure App Settings / Environment variables, you can have multiple sync source/targets configures, and multiple tables per sync job.
| Key | Description | Example |
|---|---|---|
ProcessGlobalChangeTrackingSchedule |
Custom schedule cron expression | 0 */5 * * * * |
SyncJobsConfig__Jobs__[key]__Source__ConnectionString |
Source database connection string | Server=my.dbserver.net;Initial Catalog=MySourceDb;Integrated Security=True |
SyncJobsConfig__Jobs__[key]__Source__ManagedIdentity |
Flag for if managed identity used | false |
SyncJobsConfig__Jobs__[key]__Source__TenantId |
Azure tenant ID used for managed identity | 46b41530-1e0d-4403-b815-24815944aa6a |
SyncJobsConfig__Jobs__[key]__Target__ConnectionString |
Target database connection string | Server=my.dbserver.net;Initial Catalog=MyTargetDb;Integrated Security=True |
SyncJobsConfig__Jobs__[key]__Target__ManagedIdentity |
Flag for if managed identity used | true |
SyncJobsConfig__Jobs__[key]__Target__TenantId |
Azure tenant ID used for managed identity | 46b41530-1e0d-4403-b815-24815944aa6a |
SyncJobsConfig__Jobs__[key]__BatchSize |
Bulk sync batch size | 1000 |
SyncJobsConfig__Jobs__[key]__UseSnapshotIsolationSeed |
Optional. When true, seed bulk copy reads source under Snapshot isolation (no NOLOCK). Requires ALLOW_SNAPSHOT_ISOLATION on source DB. |
true or false |
SyncJobsConfig__Jobs__[key]__UseApplicationIntentReadOnlySeed |
Optional. When true, seed bulk copy uses a separate source connection with ApplicationIntent=ReadOnly (ReadScale). Schema/CT stay on primary. |
true or false |
SyncJobsConfig__Jobs__[key]__FullSync__IntervalMilliseconds |
Optional opt-in. When any FullSync__* key is set, the job uses interval full sync (no change tracking). Minimum ms between syncs; must be > 0. |
3600000 |
SyncJobsConfig__Jobs__[key]__FullSync__UseSnapshotIsolation |
Optional. Full-sync source reads under Snapshot isolation (no NOLOCK). Requires ALLOW_SNAPSHOT_ISOLATION on source DB. |
true or false |
SyncJobsConfig__Jobs__[key]__FullSync__UseApplicationIntentReadOnly |
Optional. Full-sync source bulk reads use ApplicationIntent=ReadOnly (read scale-out). Version/clock stays on primary. |
true or false |
SyncJobsConfig__Jobs__[key]__Area |
Area name, used to manually trigger sync | Development |
SyncJobsConfig__Jobs__[key]__Manual |
Flag is sync excluded from schedules | true |
SyncJobsConfig__Jobs__[key]__Schedules__[key] |
Optional opt-in/out schedules | true |
SyncJobsConfig__Jobs__[key]__Tables__[key] |
Fully qualified name of table to sync | dbo.MyTable |
SyncJobsConfig__Jobs__[key]__DisableTargetIdentityInsertTables__[key] |
Optional, per table. When true, merge does not use IDENTITY_INSERT on target (use when target has no identity column but source does). |
true or false |
SyncJobsConfig__Jobs__[key]__DisableConstraintCheckTables__[key] |
Optional, per table. When true, disables constraint checking during merge. Useful for tables with foreign key dependencies. |
true or false |
SyncJobsConfig__Jobs__[key]__DeleteInsteadOfTruncateTables__[key] |
Optional, per table. When true, forces DELETE instead of TRUNCATE when clearing target during seed. Auto-enabled when incoming FKs are detected. |
true or false |
SyncJobsConfig__Jobs__[key]__ReseedTargetIdentityAfterClearTables__[key] |
Optional, per table. When true, runs DBCC CHECKIDENT reseed after clearing the target during seed (only when target has an identity column). |
true or false |
SyncJobsConfig__Jobs__[key]__SourceQueryTables__[key] |
Optional opt-in, per table. Custom source SELECT reading from #ChangeSet (changed primary keys); may select columns, join and filter rows. |
SELECT t.[Id], t.[Name] FROM #ChangeSet AS cs INNER JOIN dbo.[MyTable] AS t ON t.[Id] = cs.[Id] WHERE t.[IsDeleted] = 0 |
SyncJobsConfig__Jobs__[key]__SeedSourceQueryTables__[key] |
Optional, per table, requires SourceQueryTables. Seed / full-load query without #ChangeSet (avoids building a temp table of all keys). |
SELECT [Id], [Name] FROM dbo.[MyTable] WHERE [IsDeleted] = 0 |
SyncJobsConfig__Jobs__[key]__SourceQueryTriggerTables__[key]__[trigger]__Query |
Optional, per table and trigger, requires SourceQueryTables. Maps changed keys of a related table (#TriggerChangeSet) to keys of this table, so they are re-evaluated. |
SELECT t.[Id] FROM #TriggerChangeSet AS tc INNER JOIN dbo.[MyTable] AS t ON t.[CategoryId] = tc.[Id] |
SyncJobsConfig__Jobs__[key]__SourceQueryTriggerTables__[key]__[trigger]__Table |
Optional. Trigger source table; defaults to the Tables entry with the same key as [trigger]. |
dbo.[Category] |
SyncJobsConfig__Jobs__[key]__SourceQueryTargetCandidateTables__[key] |
Optional, per table, requires SourceQueryTables. Query run on the target returning keys to re-evaluate at the source on every incremental sync. |
SELECT [Id] FROM dbo.[MyTable] WHERE [Created] < DATEADD(year, -2, GETDATE()) |
SyncJobsConfig__Jobs__[key]__SourceQueryBlobTables__[key]__Path |
Optional opt-in, per table. Loads SourceQueryTables from a blob in the syncjobconfig container instead of inline config (see Blob queries). |
SyncJobsConfig/Jobs/MySync/Tables/MyTable/SourceQuery.sql |
SyncJobsConfig__Jobs__[key]__SourceQueryBlobTables__[key]__Sha512 |
Required with Path. SHA-512 hash of the blob's exact bytes, 128 hex characters (any case). |
11F45C19CF89…E692D5A113 |
SyncJobsConfig__Jobs__[key]__SeedSourceQueryBlobTables__[key]__Path / __Sha512 |
Optional. Blob alternative to SeedSourceQueryTables. |
SyncJobsConfig/Jobs/MySync/Tables/MyTable/SeedSourceQuery.sql |
SyncJobsConfig__Jobs__[key]__SourceQueryTriggerTables__[key]__[trigger]__QueryBlobPath / __QueryBlobSha512 |
Optional. Blob alternative to the trigger's Query. |
SyncJobsConfig/Jobs/MySync/Tables/MyTable/Triggers/Category.sql |
SyncJobsConfig__Jobs__[key]__SourceQueryTargetCandidateBlobTables__[key]__Path / __Sha512 |
Optional. Blob alternative to SourceQueryTargetCandidateTables. |
SyncJobsConfig/Jobs/MySync/Tables/MyTable/TargetCandidateQuery.sql |
Note:
Replace
[key]with unique name of sync job / table config i.e.MySync/MyTablewould result inSyncJobsConfig__Jobs__MySync__Tables__MyTable=dbo.MyTableApplication Name: Source and target connections report
SqlBulkSyncFunctionto SQL Server (T-SQLapp_name()/sys.dm_exec_sessions.program_name). SetApplication Name(orApp) in a connection string to override it for that database.DisableTargetIdentityInsertTables: Omit or set to
falseto copy identity values from source (default). Set totrueper table when the target schema has no identity column but the source does.DisableConstraintCheckTables: Omit or set to
falseto keep constraints enabled during merge (default). Set totrueper table when syncing tables with foreign key dependencies that may cause constraint violations due to merge order.DeleteInsteadOfTruncateTables: During seed, the target table is cleared before bulk copy.
TRUNCATEis used by default when the target is not referenced by foreign keys. When the target is referenced by other tables (detected automatically at schema load), or when this flag istrue, the service usesDELETEwithNOCHECK/CHECKon referencing tables. Set totrueto force the delete path (e.g. replication or other TRUNCATE restrictions without FK).ReseedTargetIdentityAfterClearTables: Omit or set to
falseto leave the identity seed unchanged after clear (default). Set totrueper table to runDBCC CHECKIDENTreseed to 0 after delete-based clear when the target has an identity column.UseSnapshotIsolationSeed: Omit or set to
falseto keep the default seed read (WITH(NOLOCK), no transaction). Set totruefor a consistent seed snapshot of high-churn tables; the source database must haveALTER DATABASE … SET ALLOW_SNAPSHOT_ISOLATION ON.UseApplicationIntentReadOnlySeed: Omit or set to
falseto seed from the primary source connection (default). Set totrueto offload seed bulk reads to a readable secondary (ApplicationIntent=ReadOnly); requires ReadScale (or equivalent) on the source. Change-tracking metadata is still read from the primary. Be aware of replica lag: the persisted CT version comes from the primary, so a lagged secondary seed can leave the target missing rows that incremental sync will not replay.FullSync: Omit the entire
FullSyncsection to keep change-tracking sync (default, production-safe). When anyFullSync__*key is present, the job opts into interval full sync for all tables in that job: noCHANGE_TRACKING/CHANGETABLE.sync.TableVersion.CurrentVersionstores Unix epoch milliseconds from the source clock. Scheduled runs sync only when(nowMs - lastMs) >= IntervalMilliseconds(or the table was never synced). When due, the target is reconciled without clearing: orphan delete, move new rows from staging into target, then update only changed matches. Explicit seed (POST queue/{area}/{id}/true) always clears and bulk-loads, ignoring the interval.FullSync__UseSnapshotIsolation/FullSync__UseApplicationIntentReadOnlyapply only to this mode (not the*Seedflags). Schema tracking / export HTTP endpoints remain change-tracking based and are not intended for FullSync jobs. Do not flip a job between CT and FullSync without clearingsync.TableVersionfor its tables.SourceQueryTables: Omit to keep the default table sync, which copies all source columns. When set for a table, every source read for that table goes through your query, wrapped in a generated header and footer:
- Header: creates the temp table
#ChangeSetwith the source primary key columns (same type and collation, clustered primary key) plusSYS_CHANGE_OPERATION. For incremental change-tracking sync, it holds the keys of rows inserted or updated since the last synced version (I/U, deletes excluded). It also holds keys added bySourceQueryTriggerTables(T) andSourceQueryTargetCandidateTables(C). If your query filters onSYS_CHANGE_OPERATION, that filter applies to those keys too. For seed, the first sync and FullSync, it holds all source keys (SYS_CHANGE_OPERATION=I).- Your query: should be driven by
#ChangeSet, so only changed rows are read. It can join other tables and filter rows withWHERE.- Footer: drops
#ChangeSet.Query rules:
- One
SELECTstatement that returns one result set. CTEs, subqueries,UNION,CROSS/OUTER APPLY, window functions, aggregates, views and table-valued functions are fine. Multiple statements,EXECor dynamic SQL, andGOare not supported.- Calculated and literal columns are allowed, for example
1 AS [Version]orCONCAT(t.[First], ' ', t.[Last]) AS [Name]. Every expression needs an alias, and names must be unique.- Output column names map by name (case-insensitive) to target table columns. Use
ASto rename. Every output column must exist on the target.- Column types and nullability come from the target table. Values are converted by bulk copy when written, so an incompatible value (for example text into an
int) fails at runtime.CASTexpressions to the target column type.- The query must return all primary key columns. The source and target primary keys must have the same column names.
- The query must return every target column that is
NOT NULLwithout a default. Identity, computed,rowversionand generated-always columns are exempt.Validation:
- The query is compiled (not executed) and its columns are checked against the target on every sync, before any data is touched. This mirrors the default path, which also re-reads the table schema on every run. An invalid query never clears the target.
- A query that fails validation skips only that table. The other tables in the job still sync, and the job is reported as failed.
Sync behavior:
- Locking: the header's all-keys read honors
UseSnapshotIsolationSeed/FullSync__UseSnapshotIsolation(otherwiseWITH(NOLOCK)). Your query runs at the connection's isolation level:READ COMMITTEDby default, orSNAPSHOTinside a seed or FullSync snapshot transaction. AddWITH(NOLOCK)hints in your query if you want the default path's non-blocking reads.- Deletes: on incremental sync, target rows whose key changed at source are deleted when the key is not returned by your query. That covers both rows deleted at source and rows your
WHERE/JOINnow filters out. All other returned rows are merged.- Joined tables: by default, change tracking only covers the configured source table, so a change in a joined table alone doesn't re-sync the base row. Use
SourceQueryTriggerTablesandSourceQueryTargetCandidateTables(below), schedule a periodic seed, or use FullSync.- Re-seed after changing the query: changing the query only affects rows that change afterwards.
- Message size: the source query, seed query, trigger mapping queries and target candidate query of every table are carried in the queued sync job message. Queue messages are limited to 64 KB, so keep them reasonably sized, or use Blob queries (below): only the blob path and hash are queued.
SeedSourceQueryTables: Omit to run
SourceQueryTablesover a#ChangeSetof all source keys for seed, first sync and FullSync. Set it to a query without#ChangeSetfor more efficient full loads of large tables. It must return the same columns asSourceQueryTables.SourceQueryTriggerTables: Omit to track only the synced table. Add one entry per related table whose changes affect which rows your query returns, or what it returns for them. On every incremental sync, for each trigger:
#TriggerChangeSetis filled with every changed key of the trigger table since the last synced version: its primary key columns plusSYS_CHANGE_OPERATION(I/U/D).- Only if there are changes, your mapping query runs. It must return this table's source primary key column names, and the keys it returns are added to
#ChangeSetwithSYS_CHANGE_OPERATION=T.- Your source query then re-evaluates those rows. Rows that still match are merged, and rows that no longer match are deleted from the target.
Trigger rules:
- The mapping query is one
SELECT, embedded as a derived table, so it can't use a CTE,ORDER BYorOPTION. Validation compiles it as embedded, so these fail validation rather than the sync. Extra columns are ignored, andNULLkeys are skipped.- The trigger table must have a primary key and change tracking enabled. Grant the sync user
VIEW CHANGE TRACKINGandSELECTon it.- Index the join columns used by the mapping query on the source, for example
Orders(CustomerId). Cost scales with the number of changed trigger keys and how many rows each maps to. Renaming a category used by a million rows re-syncs a million rows.- Triggers are ignored for seed, the first sync and FullSync, which read everything anyway. They are validated on every sync, and a trigger table whose change tracking retention no longer covers the last synced version fails the table with a request to re-seed.
- Change tracking has no old values. A trigger sees the current row. If a trigger row is deleted, or a mapping column changes (an order moves from customer A to B), the previous related key (customer A) can't be found. Use
SourceQueryTargetCandidateTablesfor those cases.SourceQueryTargetCandidateTables: Omit unless rows can stop matching without any change a trigger can map. Examples are a parent whose last matching child was deleted or moved, and time-based filters. The query runs on the target at the start of each incremental sync of the table and returns the target primary key column names of rows that may no longer belong. Those keys are copied into
#TargetCandidateson the source session (tempdb only) and added to#ChangeSetwithSYS_CHANGE_OPERATION=C, then re-evaluated like any changed key. Finding candidates costs the source nothing; the source only re-reads the candidate keys.
- Keep the query selective, and index its columns on the target. Candidates are re-evaluated on every sync, so return only rows that are really suspect.
- The query sees the target as it is when the table starts syncing. Changes from tables synced later in the same run are picked up on the next run.
- Tables with candidates are never skipped as "already up to date", because time-based filters can change without any source change.
Blob queries: Any of the four queries above can be kept in a
.sqlfile instead of a long single-line setting. Upload the file as a blob to thesyncjobconfigcontainer of the function'sAzureWebJobsStorageaccount (created on first use), then configure its blob name (Path) and the SHA-512 hash of the file (Sha512) instead of the inline query. The hash pins the exact content: an edited or tampered blob is never used.
Compute the hash of the exact file you upload, then upload it:
(Get-FileHash -Algorithm SHA512 .\SourceQuery.sql).Hash az storage blob upload --account-name mystorage --container-name syncjobconfig --name SyncJobsConfig/Jobs/MySync/Tables/MyTable/SourceQuery.sql --file .\SourceQuery.sql --overwrite --auth-mode login
sha512sum SourceQuery.sqlgives the same hash in lower case; either case is accepted. The hash covers every byte, so CRLF and LF line endings (watchgitautocrlf) or a UTF-8 BOM give different hashes. A UTF-8 BOM is stripped from the query text after verification.Configure one or the other: an inline query and a blob for the same query, a
PathwithoutSha512(the hash is required), or aSha512withoutPathfail validation. A blob query counts as configured wherever another setting requiresSourceQueryTables.Failures are per table: a missing blob, a hash mismatch, invalid UTF-8, a blank file or a file over 1 MiB fail only that table's validation, before any of its data is touched. Other tables still sync, and the job reports the failure. The table never falls back to the default table sync.
Fetched once: blobs are downloaded when a sync job runs (not when it's queued), and each path and hash pair is fetched once and then cached for the lifetime of the function instance. To change a query, upload the new file and update
Sha512; the new hash is fetched on the next run. Re-uploading a file without changingSha512makes that table fail with a hash mismatch, unless an instance already has the old content cached.
GET config/{area}/{id}shows the configuredpathandsha512, not the query text.Configuration from KeyVault replace
__with--i.e.SyncJobsConfig--Jobs--MySync--Tables--MyTable
Queue endpoints
Queue a job manually (Function authorization level):
| Route | Description |
|---|---|
POST queue/{area}/{id} |
Incremental sync of all tables in the job. |
POST queue/{area}/{id}/{seed} |
true: seed all tables in the job (clear target, then bulk load). false: incremental sync. |
POST queue/{area}/{id}/{seed}/{tableId} |
Same, for one table only. tableId is the table's Tables key (case-insensitive). Unknown keys return 404. |
Note:
A single-table seed (for example
POST queue/SyncTest/ProductionToDevelopment/true/TestQuery) clears and reloads only that table, with the same rules as a full seed:DELETEinstead ofTRUNCATEwhen other tables reference it. Referencing tables are not reseeded. All other job settings (snapshot isolation, read-only seed source, FullSync) apply as for the whole job.
Schedules
| Key | Description | Cron expression |
|---|---|---|
Custom |
Triggers based on configured custom schedule | ProcessGlobalChangeTrackingSchedule |
Midnight |
Triggers 00:00 / 12AM every day |
0 0 0 * * * |
Noon |
Triggers 12:00 / 12PM every day |
0 0 12 * * * |
EveryFiveMinutes |
Triggers every five minutes | 5 */5 * * * * |
EveryHour |
Triggers every hour | 10 0 * * * * |
Note:
Customschedule is default if no scheduled is specified in sync job configuration.
Schema tracking export
Asynchronous export of change-tracking data (full rows for inserts/updates, primary keys for deletes) uses the same storage account as AzureWebJobsStorage: blob container export, table exportjobs. Completed jobs also include response/existing.zip and response/missing.zip: each tracked change (I/U/D + primary key) is classified by whether that key exists on the target database—existing rows include full target column values; missing rows list only operation and primary keys. result.json exposes SAS URIs for those ZIPs (existingZipSasUri, missingZipSasUri) alongside the three segment ZIPs.
HTTP routes (Function authorization level):
POST /api/config/{area}/{id}/schema/tracking/{tableId}/export— JSON body{ "author", "referenceId", "purpose" }; returns202 AcceptedwithLocationpointing at status.GET /api/config/{area}/{id}/schema/tracking/{tableId}/export/status/{*correlationId}— same item shape as list; includes optionalresultwhenresponse/result.jsonexists.GET /api/config/{area}/{id}/schema/tracking/{tableId}/export/status— list jobs for that table partition.
Development resources
To quicker get started testing the function locally example configuration and database schema provided below
Unit tests
Tests use xUnit v3 on Microsoft Testing Platform (enabled in global.json) and are run by the Test task in cake.cs.
dotnet test --solution src/SqlBulkSyncFunction.slnx
Snapshots/DefaultPath.verified.txt contains the SQL generated for tables without SourceQueryTables. It was produced on the code from before the feature, and the test fails if that SQL changes.
Snapshots/SourceQueryPath.verified.txt and Snapshots/SeedSourceQueryPath.verified.txt do the same for SourceQueryTables tables without triggers or target candidates. They were produced on the code from before those features.
Example local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"Logging__LogLevel__Default": "Information",
"ProcessGlobalChangeTrackingSchedule": "0 23 11 * * *",
"SyncJobsConfig__Jobs__SyncTest__Area": "SyncTest",
"SyncJobsConfig__Jobs__SyncTest__Source__ConnectionString": "Server=localhost;Initial Catalog=SyncTest;Integrated Security=True",
"SyncJobsConfig__Jobs__SyncTest__Source__ManagedIdentity": false,
"SyncJobsConfig__Jobs__SyncTest__Target__ConnectionString": "Server=localhost;Initial Catalog=SyncTest;Integrated Security=True",
"SyncJobsConfig__Jobs__SyncTest__Target__ManagedIdentity": false,
"SyncJobsConfig__Jobs__SyncTest__BatchSize": 1000,
"SyncJobsConfig__Jobs__SyncTest__Manual": false,
"SyncJobsConfig__Jobs__SyncTest__Tables__Test": "source.[Test]",
"SyncJobsConfig__Jobs__SyncTest__TargetTables__Test": "target.[Test]",
"SyncJobsConfig__Jobs__SyncTest__Schedules__Custom": true,
"SyncJobsConfig__Jobs__SyncTest__Schedules__Noon": true,
"SyncJobsConfig__Jobs__SyncTest__Schedules__Midnight": true,
"SyncJobsConfig__Jobs__SyncTest__Schedules__EveryFiveMinutes": true,
"SyncJobsConfig__Jobs__SyncTest__Schedules__EveryHour": true
}
}
Example .env file for Docker
# Environment variables for running SqlBulkSyncFunction in Docker
AzureWebJobsStorage=UseDevelopmentStorage=true
FUNCTIONS_WORKER_RUNTIME=dotnet-isolated
ProcessGlobalChangeTrackingSchedule=0 23 11 * * *
SyncJobsConfig__Jobs__SyncTest__Area=SyncTest
SyncJobsConfig__Jobs__SyncTest__Source__ConnectionString=Server=localhost;Initial Catalog=SyncTest;Integrated Security=True
SyncJobsConfig__Jobs__SyncTest__Source__ManagedIdentity=false
SyncJobsConfig__Jobs__SyncTest__Target__ConnectionString=Server=localhost;Initial Catalog=SyncTest;Integrated Security=True
SyncJobsConfig__Jobs__SyncTest__Target__ManagedIdentity=false
SyncJobsConfig__Jobs__SyncTest__BatchSize=1000
SyncJobsConfig__Jobs__SyncTest__Manual=false
SyncJobsConfig__Jobs__SyncTest__Tables__Test=source.[Test]
SyncJobsConfig__Jobs__SyncTest__TargetTables__Test=target.[Test]
SyncJobsConfig__Jobs__SyncTest__Schedules__Custom=true
SyncJobsConfig__Jobs__SyncTest__Schedules__Noon=true
SyncJobsConfig__Jobs__SyncTest__Schedules__Midnight=true
SyncJobsConfig__Jobs__SyncTest__Schedules__EveryFiveMinutes=true
SyncJobsConfig__Jobs__SyncTest__Schedules__EveryHour=true
Example database seed script
Run the source script first (creates database and change tracking), then the target script.
Source (database, schema, table, change tracking, seed data):
-- Create Database
CREATE DATABASE [SyncTest]
GO
USE [SyncTest]
GO
ALTER DATABASE [SyncTest]
SET CHANGE_TRACKING = ON (
CHANGE_RETENTION = 7 DAYS,
AUTO_CLEANUP = ON
)
GO
-- Create source schema and table
CREATE SCHEMA [source]
GO
CREATE TABLE [source].[Test](
[Id] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Description] [nvarchar](256) NULL,
[Created] [datetime] NOT NULL
)
GO
ALTER TABLE [source].[Test] ENABLE CHANGE_TRACKING WITH(TRACK_COLUMNS_UPDATED = ON)
GO
-- Seed data
INSERT INTO source.[Test]
(
Description,
Created
) VALUES (
'Row 1',
GETDATE()
)
GO
INSERT INTO source.[Test]
(
Description,
Created
) VALUES (
'Row 2',
GETDATE()
)
Target (schema and table):
USE [SyncTest]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE SCHEMA [target]
GO
CREATE TABLE [target].[Test](
[Id] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Description] [nvarchar](256) NULL,
[Created] [datetime] NOT NULL
)
GO
Example permissions for sync
Grant the identity that runs the sync (e.g. managed identity or SQL login) the permissions below. Replace [your-sync-identity] with that principal.
Source database (read and change tracking):
USE [SyncTest]
GO
CREATE ROLE [SyncOperator]
GO
ALTER ROLE [SyncOperator] ADD MEMBER [your-sync-identity]
GO
-- Per table: change tracking, definition, and read
GRANT VIEW CHANGE TRACKING ON [source].[Test] TO [SyncOperator]
GO
GRANT VIEW DEFINITION ON [source].[Test] TO [SyncOperator]
GO
GRANT SELECT ON [source].[Test] TO [SyncOperator]
GO
Target database (sync schema and table DML):
USE [SyncTest]
GO
CREATE ROLE [SyncOperatorTarget]
GO
ALTER ROLE [SyncOperatorTarget] ADD MEMBER [your-sync-identity]
GO
-- Schema for sync metadata tables
CREATE SCHEMA [sync]
GO
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER, CONTROL ON SCHEMA::[sync] TO [SyncOperatorTarget]
GO
ALTER AUTHORIZATION ON SCHEMA::[sync] TO [SyncOperatorTarget]
GO
GRANT CREATE TABLE TO [SyncOperatorTarget]
GO
-- Per target table: DML and ALTER (e.g. for sync metadata)
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON [target].[Test] TO [SyncOperatorTarget]
GO
Custom source query example
This example adds a TestQuery table to the SyncTest database. It uses SourceQueryTables to:
- sync only rows where
IsDeleted = 0 - skip the
CategoryIdandIsDeletedcolumns - join
source.[Category]to sync the category name into aCategoryNamecolumn on the target
Source (tables, change tracking, seed data, permissions):
USE [SyncTest]
GO
CREATE TABLE [source].[Category](
[Id] [int] NOT NULL PRIMARY KEY,
[Name] [nvarchar](100) NOT NULL
)
GO
CREATE TABLE [source].[TestQuery](
[Id] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Description] [nvarchar](256) NULL,
[CategoryId] [int] NULL REFERENCES [source].[Category]([Id]),
[IsDeleted] [bit] NOT NULL DEFAULT(0),
[Created] [datetime] NOT NULL
)
GO
-- Change tracking is needed on the synced table, and on joined tables only when used as triggers
ALTER TABLE [source].[TestQuery] ENABLE CHANGE_TRACKING WITH(TRACK_COLUMNS_UPDATED = ON)
GO
-- Optional: lets Category renames re-sync TestQuery rows (SourceQueryTriggerTables)
ALTER TABLE [source].[Category] ENABLE CHANGE_TRACKING
GO
CREATE INDEX [IX_TestQuery_CategoryId] ON [source].[TestQuery]([CategoryId])
GO
-- Seed data
INSERT INTO [source].[Category] ([Id], [Name])
VALUES (1, 'Hardware'),
(2, 'Software')
GO
INSERT INTO [source].[TestQuery] ([Description], [CategoryId], [IsDeleted], [Created])
VALUES ('Row 1', 1, 0, GETDATE()),
('Row 2', 2, 0, GETDATE()),
('Row 3', NULL, 0, GETDATE()),
('Row 4 (soft deleted, not synced)', 1, 1, GETDATE())
GO
-- Permissions: the query reads joined tables too, so grant SELECT on them
GRANT VIEW CHANGE TRACKING ON [source].[TestQuery] TO [SyncOperator]
GO
GRANT VIEW DEFINITION ON [source].[TestQuery] TO [SyncOperator]
GO
GRANT SELECT ON [source].[TestQuery] TO [SyncOperator]
GO
GRANT SELECT ON [source].[Category] TO [SyncOperator]
GO
-- Only needed for the Category trigger
GRANT VIEW CHANGE TRACKING ON [source].[Category] TO [SyncOperator]
GO
GRANT VIEW DEFINITION ON [source].[Category] TO [SyncOperator]
GO
Target (table and permissions):
USE [SyncTest]
GO
CREATE TABLE [target].[TestQuery](
[Id] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Description] [nvarchar](256) NULL,
[CategoryName] [nvarchar](100) NULL,
[Created] [datetime] NOT NULL
)
GO
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON [target].[TestQuery] TO [SyncOperatorTarget]
GO
Source query (shown formatted; in configuration it must be a single line):
SELECT t.[Id],
t.[Description],
c.[Name] AS [CategoryName],
t.[Created]
FROM #ChangeSet AS cs
INNER JOIN source.[TestQuery] AS t ON t.[Id] = cs.[Id]
LEFT JOIN source.[Category] AS c ON c.[Id] = t.[CategoryId]
WHERE t.[IsDeleted] = 0
Configuration (local.settings.json, added to the SyncTest job's Values):
"SyncJobsConfig__Jobs__SyncTest__Tables__TestQuery": "source.[TestQuery]",
"SyncJobsConfig__Jobs__SyncTest__TargetTables__TestQuery": "target.[TestQuery]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTables__TestQuery": "SELECT t.[Id], t.[Description], c.[Name] AS [CategoryName], t.[Created] FROM #ChangeSet AS cs INNER JOIN source.[TestQuery] AS t ON t.[Id] = cs.[Id] LEFT JOIN source.[Category] AS c ON c.[Id] = t.[CategoryId] WHERE t.[IsDeleted] = 0"
Configuration (.env for Docker):
SyncJobsConfig__Jobs__SyncTest__Tables__TestQuery=source.[TestQuery]
SyncJobsConfig__Jobs__SyncTest__TargetTables__TestQuery=target.[TestQuery]
SyncJobsConfig__Jobs__SyncTest__SourceQueryTables__TestQuery=SELECT t.[Id], t.[Description], c.[Name] AS [CategoryName], t.[Created] FROM #ChangeSet AS cs INNER JOIN source.[TestQuery] AS t ON t.[Id] = cs.[Id] LEFT JOIN source.[Category] AS c ON c.[Id] = t.[CategoryId] WHERE t.[IsDeleted] = 0
Optionally, add a seed / full-load query that skips building #ChangeSet over every key. This is useful for large tables:
"SyncJobsConfig__Jobs__SyncTest__SeedSourceQueryTables__TestQuery": "SELECT t.[Id], t.[Description], c.[Name] AS [CategoryName], t.[Created] FROM source.[TestQuery] AS t LEFT JOIN source.[Category] AS c ON c.[Id] = t.[CategoryId] WHERE t.[IsDeleted] = 0"
Alternatively, keep the source query readable in a file (see Blob queries). Save the query above as SourceQuery.sql, upload it to the syncjobconfig container (for Azurite: --connection-string UseDevelopmentStorage=true), and replace SourceQueryTables__TestQuery with:
"SyncJobsConfig__Jobs__SyncTest__SourceQueryBlobTables__TestQuery__Path": "SyncJobsConfig/Jobs/SyncTest/Tables/TestQuery/SourceQuery.sql",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryBlobTables__TestQuery__Sha512": "<(Get-FileHash -Algorithm SHA512 .\\SourceQuery.sql).Hash>"
Optionally, re-sync rows when their category changes (requires change tracking on source.[Category], see above). Category isn't a key in Tables, so Table is set:
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__TestQuery__Category__Table": "source.[Category]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__TestQuery__Category__Query": "SELECT t.[Id] FROM #TriggerChangeSet AS tc INNER JOIN source.[TestQuery] AS t ON t.[CategoryId] = tc.[Id]"
Expected result after a seed (POST queue/SyncTest/SyncTest/true):
target.[TestQuery]contains rows 1–3, withCategoryNameHardware,SoftwareandNULL.- Row 4 is not synced.
- Running
UPDATE source.[TestQuery] SET IsDeleted = 1 WHERE Id = 1then an incremental sync removes row 1 from the target. - Running
UPDATE source.[Category] SET Name = 'SW' WHERE Id = 2then an incremental sync updatesCategoryNameof row 2 toSWwith the Category trigger. Without the trigger, rows are not re-synced, because only changes tosource.[TestQuery]are tracked.
Source query triggers and target candidates example
This example syncs Customers, Orders and OrderDetails, but only customers and orders that match these filters:
-- <C> customer filter
c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1)
-- <O> order filter
o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'
- Orders:
<C>and<O>match. TriggerCustomersre-evaluates a customer's orders when the customer changes. - OrderDetails: their order matches
<C>and<O>. TriggerOrdersre-evaluates an order's details, and triggerCustomersre-evaluates all details of a customer's orders. - Customers:
<C>matches and the customer has at least one matching order.- Trigger
Ordersre-evaluates the current customer of a changed order. - The target candidate query re-evaluates customers left on the target without any synced order. That covers deleted and moved orders, whose previous customer change tracking can't provide.
- Trigger
Source (tables, change tracking, permissions):
USE [SyncTest]
GO
CREATE TABLE [source].[Customers](
[CustomerId] [int] NOT NULL PRIMARY KEY,
[Name] [nvarchar](100) NOT NULL,
[Country] [char](2) NOT NULL,
[CustomerStatus] [tinyint] NOT NULL,
[AcceptEmail] [bit] NOT NULL,
[AcceptSMS] [bit] NOT NULL
)
GO
CREATE TABLE [source].[Orders](
[OrderId] [int] NOT NULL PRIMARY KEY,
[CustomerId] [int] NOT NULL REFERENCES [source].[Customers]([CustomerId]),
[Country] [char](2) NOT NULL,
[OrderStatus] [tinyint] NOT NULL,
[OrderDate] [date] NOT NULL
)
GO
CREATE INDEX [IX_Orders_CustomerId] ON [source].[Orders]([CustomerId])
GO
CREATE TABLE [source].[OrderDetails](
[OrderDetailId] [int] NOT NULL PRIMARY KEY,
[OrderId] [int] NOT NULL REFERENCES [source].[Orders]([OrderId]),
[Product] [nvarchar](100) NOT NULL,
[Quantity] [int] NOT NULL
)
GO
CREATE INDEX [IX_OrderDetails_OrderId] ON [source].[OrderDetails]([OrderId])
GO
ALTER TABLE [source].[Customers] ENABLE CHANGE_TRACKING
GO
ALTER TABLE [source].[Orders] ENABLE CHANGE_TRACKING
GO
ALTER TABLE [source].[OrderDetails] ENABLE CHANGE_TRACKING
GO
GRANT VIEW CHANGE TRACKING, VIEW DEFINITION, SELECT ON [source].[Customers] TO [SyncOperator]
GO
GRANT VIEW CHANGE TRACKING, VIEW DEFINITION, SELECT ON [source].[Orders] TO [SyncOperator]
GO
GRANT VIEW CHANGE TRACKING, VIEW DEFINITION, SELECT ON [source].[OrderDetails] TO [SyncOperator]
GO
Target (tables and permissions):
USE [SyncTest]
GO
CREATE TABLE [target].[Customers](
[CustomerId] [int] NOT NULL PRIMARY KEY,
[Name] [nvarchar](100) NOT NULL,
[Country] [char](2) NOT NULL,
[CustomerStatus] [tinyint] NOT NULL,
[AcceptEmail] [bit] NOT NULL,
[AcceptSMS] [bit] NOT NULL
)
GO
CREATE TABLE [target].[Orders](
[OrderId] [int] NOT NULL PRIMARY KEY,
[CustomerId] [int] NOT NULL,
[Country] [char](2) NOT NULL,
[OrderStatus] [tinyint] NOT NULL,
[OrderDate] [date] NOT NULL
)
GO
-- Used by the Customers target candidate query
CREATE INDEX [IX_Orders_CustomerId] ON [target].[Orders]([CustomerId])
GO
CREATE TABLE [target].[OrderDetails](
[OrderDetailId] [int] NOT NULL PRIMARY KEY,
[OrderId] [int] NOT NULL,
[Product] [nvarchar](100) NOT NULL,
[Quantity] [int] NOT NULL
)
GO
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON [target].[Customers] TO [SyncOperatorTarget]
GO
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON [target].[Orders] TO [SyncOperatorTarget]
GO
GRANT SELECT, INSERT, DELETE, UPDATE, ALTER ON [target].[OrderDetails] TO [SyncOperatorTarget]
GO
Queries (shown formatted; in configuration each must be a single line):
-- SourceQueryTables__Orders
SELECT o.[OrderId], o.[CustomerId], o.[Country], o.[OrderStatus], o.[OrderDate]
FROM #ChangeSet AS cs
INNER JOIN source.[Orders] AS o ON o.[OrderId] = cs.[OrderId]
INNER JOIN source.[Customers] AS c ON c.[CustomerId] = o.[CustomerId]
WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1)
AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'
-- SourceQueryTriggerTables__Orders__Customers__Query: a customer changed, re-evaluate its orders
SELECT o.[OrderId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[CustomerId] = tc.[CustomerId]
-- SourceQueryTables__OrderDetails
SELECT od.[OrderDetailId], od.[OrderId], od.[Product], od.[Quantity]
FROM #ChangeSet AS cs
INNER JOIN source.[OrderDetails] AS od ON od.[OrderDetailId] = cs.[OrderDetailId]
INNER JOIN source.[Orders] AS o ON o.[OrderId] = od.[OrderId]
INNER JOIN source.[Customers] AS c ON c.[CustomerId] = o.[CustomerId]
WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1)
AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'
-- SourceQueryTriggerTables__OrderDetails__Orders__Query: an order changed, re-evaluate its details
SELECT od.[OrderDetailId] FROM #TriggerChangeSet AS tc INNER JOIN source.[OrderDetails] AS od ON od.[OrderId] = tc.[OrderId]
-- SourceQueryTriggerTables__OrderDetails__Customers__Query: a customer changed, re-evaluate details of its orders
SELECT od.[OrderDetailId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[CustomerId] = tc.[CustomerId] INNER JOIN source.[OrderDetails] AS od ON od.[OrderId] = o.[OrderId]
-- SourceQueryTables__Customers
SELECT c.[CustomerId], c.[Name], c.[Country], c.[CustomerStatus], c.[AcceptEmail], c.[AcceptSMS]
FROM #ChangeSet AS cs
INNER JOIN source.[Customers] AS c ON c.[CustomerId] = cs.[CustomerId]
WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1)
AND EXISTS (
SELECT 1
FROM source.[Orders] AS o
WHERE o.[CustomerId] = c.[CustomerId]
AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'
)
-- SourceQueryTriggerTables__Customers__Orders__Query: an order changed, re-evaluate its current customer
SELECT o.[CustomerId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[OrderId] = tc.[OrderId]
-- SourceQueryTargetCandidateTables__Customers (runs on the target): customers without any synced order
SELECT c.[CustomerId] FROM target.[Customers] AS c WHERE NOT EXISTS (SELECT 1 FROM target.[Orders] AS o WHERE o.[CustomerId] = c.[CustomerId])
Configuration (local.settings.json, added to the SyncTest job's Values):
"SyncJobsConfig__Jobs__SyncTest__Tables__Customers": "source.[Customers]",
"SyncJobsConfig__Jobs__SyncTest__Tables__Orders": "source.[Orders]",
"SyncJobsConfig__Jobs__SyncTest__Tables__OrderDetails": "source.[OrderDetails]",
"SyncJobsConfig__Jobs__SyncTest__TargetTables__Customers": "target.[Customers]",
"SyncJobsConfig__Jobs__SyncTest__TargetTables__Orders": "target.[Orders]",
"SyncJobsConfig__Jobs__SyncTest__TargetTables__OrderDetails": "target.[OrderDetails]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTables__Orders": "SELECT o.[OrderId], o.[CustomerId], o.[Country], o.[OrderStatus], o.[OrderDate] FROM #ChangeSet AS cs INNER JOIN source.[Orders] AS o ON o.[OrderId] = cs.[OrderId] INNER JOIN source.[Customers] AS c ON c.[CustomerId] = o.[CustomerId] WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1) AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__Orders__Customers__Query": "SELECT o.[OrderId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[CustomerId] = tc.[CustomerId]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTables__OrderDetails": "SELECT od.[OrderDetailId], od.[OrderId], od.[Product], od.[Quantity] FROM #ChangeSet AS cs INNER JOIN source.[OrderDetails] AS od ON od.[OrderDetailId] = cs.[OrderDetailId] INNER JOIN source.[Orders] AS o ON o.[OrderId] = od.[OrderId] INNER JOIN source.[Customers] AS c ON c.[CustomerId] = o.[CustomerId] WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1) AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01'",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__OrderDetails__Orders__Query": "SELECT od.[OrderDetailId] FROM #TriggerChangeSet AS tc INNER JOIN source.[OrderDetails] AS od ON od.[OrderId] = tc.[OrderId]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__OrderDetails__Customers__Query": "SELECT od.[OrderDetailId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[CustomerId] = tc.[CustomerId] INNER JOIN source.[OrderDetails] AS od ON od.[OrderId] = o.[OrderId]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTables__Customers": "SELECT c.[CustomerId], c.[Name], c.[Country], c.[CustomerStatus], c.[AcceptEmail], c.[AcceptSMS] FROM #ChangeSet AS cs INNER JOIN source.[Customers] AS c ON c.[CustomerId] = cs.[CustomerId] WHERE c.[Country] IN ('SE', 'UK') AND c.[CustomerStatus] IN (1, 3) AND (c.[AcceptEmail] = 1 OR c.[AcceptSMS] = 1) AND EXISTS (SELECT 1 FROM source.[Orders] AS o WHERE o.[CustomerId] = c.[CustomerId] AND o.[Country] IN ('SE', 'UK') AND o.[OrderStatus] IN (1, 2, 5) AND o.[OrderDate] >= '2020-01-01')",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTriggerTables__Customers__Orders__Query": "SELECT o.[CustomerId] FROM #TriggerChangeSet AS tc INNER JOIN source.[Orders] AS o ON o.[OrderId] = tc.[OrderId]",
"SyncJobsConfig__Jobs__SyncTest__SourceQueryTargetCandidateTables__Customers": "SELECT c.[CustomerId] FROM target.[Customers] AS c WHERE NOT EXISTS (SELECT 1 FROM target.[Orders] AS o WHERE o.[CustomerId] = c.[CustomerId])"
Check query (run on the target after each step):
SELECT 'Customers' AS [Table], STRING_AGG(CAST([CustomerId] AS varchar(10)), ',') WITHIN GROUP (ORDER BY [CustomerId]) AS [Keys] FROM [target].[Customers]
UNION ALL
SELECT 'Orders', STRING_AGG(CAST([OrderId] AS varchar(10)), ',') WITHIN GROUP (ORDER BY [OrderId]) FROM [target].[Orders]
UNION ALL
SELECT 'OrderDetails', STRING_AGG(CAST([OrderDetailId] AS varchar(10)), ',') WITHIN GROUP (ORDER BY [OrderDetailId]) FROM [target].[OrderDetails]
Step 1: insert seed data, then seed (POST queue/SyncTest/SyncTest/true):
INSERT INTO [source].[Customers] ([CustomerId], [Name], [Country], [CustomerStatus], [AcceptEmail], [AcceptSMS])
VALUES (1, 'Alice', 'SE', 1, 1, 0), -- in
(2, 'Bob', 'UK', 3, 0, 1), -- in
(3, 'Carl', 'DE', 1, 1, 1), -- out: country
(4, 'Dana', 'SE', 2, 1, 0), -- out: status
(5, 'Eve', 'SE', 1, 0, 0) -- out: no consent
INSERT INTO [source].[Orders] ([OrderId], [CustomerId], [Country], [OrderStatus], [OrderDate])
VALUES (101, 1, 'SE', 1, '2021-05-01'), -- in
(102, 1, 'SE', 3, '2021-06-01'), -- out: order status
(103, 2, 'UK', 2, '2019-12-31'), -- out: order date
(104, 2, 'UK', 5, '2022-01-10'), -- in
(105, 3, 'DE', 1, '2022-01-01'), -- out: country
(106, 4, 'SE', 1, '2022-02-01') -- out: customer 4 status
INSERT INTO [source].[OrderDetails] ([OrderDetailId], [OrderId], [Product], [Quantity])
VALUES (1001, 101, 'Pen', 1),
(1002, 101, 'Ink', 2),
(1003, 102, 'Pad', 1),
(1004, 104, 'Cup', 3),
(1005, 106, 'Mug', 1)
GO
| Table | Expected keys after step 1 |
|---|---|
| Customers | 1,2 |
| Orders | 101,104 |
| OrderDetails | 1001,1002,1004 |
Step 2: changes resolved by triggers, then one incremental sync (POST queue/SyncTest/SyncTest):
UPDATE [source].[Customers] SET [CustomerStatus] = 1 WHERE [CustomerId] = 4 -- customer now matches: brings in order 106 and detail 1005
UPDATE [source].[Orders] SET [OrderStatus] = 2 WHERE [OrderId] = 102 -- order now matches: brings in detail 1003
UPDATE [source].[Orders] SET [OrderStatus] = 4 WHERE [OrderId] = 104 -- order leaves the filter: removes 104, detail 1004 and customer 2 (no matching order left)
INSERT INTO [source].[Customers] ([CustomerId], [Name], [Country], [CustomerStatus], [AcceptEmail], [AcceptSMS])
VALUES (6, 'Fia', 'UK', 3, 1, 0)
INSERT INTO [source].[Orders] ([OrderId], [CustomerId], [Country], [OrderStatus], [OrderDate])
VALUES (108, 6, 'UK', 5, '2024-03-01')
INSERT INTO [source].[OrderDetails] ([OrderDetailId], [OrderId], [Product], [Quantity])
VALUES (1006, 108, 'Box', 1)
GO
| Table | Expected keys after step 2 |
|---|---|
| Customers | 1,4,6 |
| Orders | 101,102,106,108 |
| OrderDetails | 1001,1002,1003,1005,1006 |
Step 3: changes that need target candidates, then up to two incremental syncs. Two syncs are needed when Customers syncs before Orders in the same run.
DELETE FROM [source].[OrderDetails] WHERE [OrderDetailId] = 1005
DELETE FROM [source].[Orders] WHERE [OrderId] = 106 -- deleted: change tracking has no CustomerId, the candidate query removes customer 4
UPDATE [source].[Orders] SET [CustomerId] = 1 WHERE [OrderId] = 108 -- moved: the trigger re-evaluates customer 1, the candidate query removes customer 6
GO
| Table | Expected keys after step 3 |
|---|---|
| Customers | 1 |
| Orders | 101,102,108 |
| OrderDetails | 1001,1002,1003,1006 |
Without SourceQueryTargetCandidateTables__Customers, customers 4 and 6 stay on the target after step 3.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AsyncEnumerator (>= 4.0.2)
- Azure.Data.Tables (>= 12.13.0)
- Azure.Identity (>= 1.21.0)
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.10.0)
- Cronos (>= 0.13.0)
- Dapper (>= 2.1.100)
- Microsoft.Azure.Functions.Worker (>= 2.52.0)
- Microsoft.Azure.Functions.Worker.Extensions.Http (>= 3.3.0)
- Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore (>= 2.1.1)
- Microsoft.Azure.Functions.Worker.Extensions.OpenApi (>= 1.6.0)
- Microsoft.Azure.Functions.Worker.Extensions.Storage (>= 6.8.2)
- Microsoft.Azure.Functions.Worker.Extensions.Timer (>= 4.3.1)
- Microsoft.Azure.Functions.Worker.OpenTelemetry (>= 1.2.0)
- Microsoft.Azure.Functions.Worker.Sdk (>= 2.1.0)
- Microsoft.Data.SqlClient (>= 8.0.0)
- Microsoft.Data.SqlClient.Extensions.Azure (>= 8.0.0)
- OpenTelemetry.Exporter.Console (>= 1.21.0)
- OpenTelemetry.Extensions.Hosting (>= 1.21.0)
- System.Security.Cryptography.Pkcs (>= 10.0.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.12.3.572 | 0 | 12/3/2026 |
| 2026.12.3.570 | 0 | 12/3/2026 |
| 2026.12.2.565 | 47 | 12/2/2026 |
| 2026.12.2.563 | 56 | 12/2/2026 |
| 2026.11.27.557 | 87 | 11/27/2026 |
| 2026.11.27.552 | 77 | 11/27/2026 |
| 2026.11.22.546 | 114 | 11/22/2026 |
| 2026.11.17.542 | 119 | 11/17/2026 |
| 2026.11.13.538 | 151 | 11/13/2026 |
| 2026.11.13.536 | 125 | 11/13/2026 |
| 2026.11.12.531 | 119 | 11/12/2026 |
| 2026.11.12.527 | 111 | 11/12/2026 |
| 2026.11.12.525 | 118 | 11/12/2026 |
| 2026.11.12.523 | 113 | 11/12/2026 |
| 2026.11.12.521 | 128 | 11/12/2026 |
| 2026.11.12.519 | 119 | 11/12/2026 |
| 2026.10.27.512 | 162 | 10/27/2026 |
| 2026.10.27.510 | 140 | 10/27/2026 |
| 2026.10.26.507 | 153 | 10/26/2026 |
| 2026.10.21.503 | 147 | 10/21/2026 |