A lot of teams run real operations in Quickbase and still need that data in SQL for reporting, Power BI or joins with other systems. The usual answer is a nightly export or a Pipeline to somewhere else. I wanted something closer to live, with no secrets in app settings and no records silently dropped. This post walks through a timer-triggered Azure Function that copies changed Quickbase records into Azure SQL every 15 minutes.
The full sample is in the repo: samples/FunctionsSync. It uses QuickbaseNet, a .NET client for the Quickbase REST API that I wrote and maintain.
The shape of it
- A timer trigger runs every 15 minutes.
- It reads a watermark (the last Date Modified it saw) from a small SyncState table.
- It queries Quickbase for records modified on or after that watermark, pages through them and MERGEs them into Azure SQL in batches of 500.
- Each batch and the new watermark commit in one transaction.
- The Function App's managed identity reads the Quickbase user token from Key Vault and signs in to Azure SQL. There is no connection string password and no token in app settings.
Mapping the table
Fids go on a partial class. A source generator writes the mapping at build time, so there is no reflection at runtime.
public sealed partial class Project
{
[Fid(3)] public long Rid { get; set; }
[Fid(2, ReadOnly = true)] public DateTimeOffset Modified { get; set; }
[Fid(6)] public string? Name { get; set; }
[Fid(7)] public string? Status { get; set; }
[Fid(8)] public decimal? Budget { get; set; }
[Fid(9)] public DateOnly? Due { get; set; }
}
The query
var query = new RecordQuery
{
From = tableId,
Where = Filter.Fid(2).OnOrAfter(since),
SortBy = [Sort.Asc(2), Sort.Asc(3)],
Options = new QueryOptions { Top = 500 },
};
await foreach (var project in qb.Records.QueryAllAsync<Project>(query, cancellationToken))
{
// add to batch, save every 500
}
Three details matter here.
- OnOrAfter, not After. Two records can share the watermark's exact timestamp. With After, the second one is lost forever. With OnOrAfter you re-read the boundary record, which costs nothing because the MERGE is idempotent.
- Sort by Date Modified, then Record ID. A record edited while the sync is paging gets a newer Date Modified, moves to the end of the sort order and is picked up on the next run.
-
Page by records received. Quickbase caps each response by payload size as well as by
top, so a page of 500 can come back with 312 records even when more remain. Code that addstoptoskipevery time skips the other 188.QueryAllAsyncmovesskipby the number of records that actually arrived and stops attotalRecords. This is the bug I see most often in hand-written Quickbase sync code, and it only shows up on wide tables.
Writing to SQL
Each batch runs a MERGE per record and then updates the watermark, all inside one transaction:
// Watermark and rows commit together, so a crash never skips records on the next run.
await store.SaveAsync(tableId, batch, watermark, cancellationToken);
If the function dies halfway, the next run starts from the last committed watermark and re-reads anything after it.
Tokens from Key Vault
builder.Services.AddQuickbase(config.GetSection("Quickbase"));
builder.Services.AddOptions<QuickbaseOptions>()
.Configure<VaultToken>((options, vault) => options.TokenSource = vault.GetAsync);
VaultToken caches the secret for ten minutes. Rotate the token in Key Vault and the function picks it up without a restart. Locally, DefaultAzureCredential uses your az login, so the same code runs on your machine.
Throttling and retries
Quickbase returns 429 when you push too hard. The client retries 429, 502, 503 and 504, honors Retry-After and adds jitter so several instances don't retry in lockstep. You get a QuickbaseException with the QB-API-RAY request ID if it finally fails, which is the first thing Quickbase support asks for.
Running it
- Create the tables from
sql/schema.sqland grant the Function App's identitydb_datareaderanddb_datawriter. - Put your Quickbase user token in Key Vault and give the identity "Key Vault Secrets User".
- Copy
local.settings.example.json, set your realm, table ID and vault, and runfunc start. - Change the fids in
Project.csto match your table.
Try it
dotnet add package QuickbaseDotNet
The library also covers reports, upserts with line errors mapped back to your input rows, deletes that refuse an empty filter, and OpenTelemetry traces and metrics. It targets .NET 10 and netstandard2.0, so it works on .NET Framework 4.6.2 too. It is unofficial and not affiliated with Quickbase, Inc.
Issues and questions are welcome on GitHub. If you sync Quickbase some other way, I'd like to hear how you handle the watermark.
Top comments (0)