SmartTableSync.Templates
0.5.4
dotnet new install SmartTableSync.Templates@0.5.4
SmartTableSync.Templates
dotnet new template for SmartTableSync: an Azure
Function that keeps tables in a child Azure SQL database up to date with a parent database, with a
script and Terraform that deploy it and start the first sync.
Install and create a project
dotnet new install SmartTableSync.Templates
dotnet new smarttablesync-azure -n MySync
cd MySync
The project uses the SmartTableSync package and the SmartTableSync.Scaffold tool, in the same version as this template. Its packages are restored as soon as it is created.
MySync/
├── MySync/ the Function (references the SmartTableSync package)
├── quickstart/deploy.ps1 deploys it to Azure and starts the first sync
├── quickstart/terraform/ the Azure resources
├── .config/dotnet-tools.json the scaffold tool, for Manual mode
└── README.md
Deploy it
First, if you want SQL Server Change Tracking (the best way to find changed rows; the table
needs a primary key), turn it on in the parent for each table, or add -EnableChangeTracking to
the command below:
ALTER DATABASE CURRENT SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
ALTER TABLE dbo.Product ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF);
Without it, tables sync with a rowversion column, a timestamp column or a full re-scan. Then:
az login
./quickstart/deploy.ps1 -Suffix acme1 `
-ParentConnectionString $env:PARENT_DB -ChildConnectionString $env:CHILD_DB `
-Tables "Product,Customer"
acme1 is only an example: give each deployment its own -Suffix (3-8 lowercase letters or
digits), unique in the subscription. The script stops if another folder or machine already
deployed with that suffix.
What you need and every parameter: the quick start guide.
Update or remove the template
dotnet new update
dotnet new uninstall SmartTableSync.Templates
License
Apache-2.0
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
SmartTableSync now shows up by name in SQL Server, the quick start explains a reused suffix
instead of failing in Terraform, and there are clear ways to give feedback.
### Added
- SmartTableSync's connections show up in SQL Server as `SmartTableSync`, and the scaffold tool's
as `SmartTableSync.Scaffold` (`APP_NAME()`, `sys.dm_exec_sessions.program_name`), so a DBA can
see which sessions are the sync. An `Application Name` in the connection string still wins.
See [connection strings](docs/configuration.md#connection-strings).
- Issue forms for bugs and feature requests, links to Discussions for questions and for sharing a
setup, a [contributing guide](CONTRIBUTING.md), and a feedback section in the README and on the
NuGet package page.
### Changed
- The quick start stops before Terraform, with a clear message, when the suffix's resource group
already exists but another folder or machine created it. Before, Terraform failed at apply with
"a resource with the ID ... already exists". The docs say that `acme1` is only an example.
- A connection string that can't be read now stops the sync at startup with a message naming the
setting (for example *"ChildDbConnectionString isn't a valid connection string"*), instead of at
the first connection.
### Upgrading
Nothing to change. If you filter SQL Server sessions or audit logs by program name, they now show
`SmartTableSync` instead of SqlClient's default; set `Application Name` in the connection strings
to keep a name of your own.
### Tested
- Unit and integration tests (303 and 74) pass, including new ones that check `APP_NAME()` and
`sys.dm_exec_sessions.program_name` on a real SQL Server, with and without an `Application
Name` in the connection string.
- The quick start's suffix check on Azure: it stops for a resource group that exists but isn't in
the folder's Terraform state, and continues for a new suffix, a deleted one, and the folder's own
deployment.
Full changelog: https://github.com/Sidorus/SmartTableSync/blob/main/CHANGELOG.md