Contents
SQL Files for Azure Functions Scenario
This directory contains runnable SQL scripts for calling Azure Functions from pg_durable.
Tables used
demo.af_documents: source rows waiting to be chunkeddemo.af_document_chunks: output rows, one per chunk
Workflow shape
- Select pending document rows.
- Build JSON request payload for one document.
- Call Azure Function via
df.http(). - Validate HTTP envelope (
ok,status). - Parse response body JSON and insert chunk rows.
- Mark source document as processed.
Variable usage
Set before df.start():
azure_function_base_urlazure_function_key
Use variable substitution in workflow SQL where applicable.
Error handling
- Handle 4xx in SQL branch logic (bad payload, auth issues).
- Allow 5xx/network failures to fail activity and rely on durable retry behavior.
- Persist concise diagnostics in an audit/log table if needed.
SQL files
01_schema.sql: demo schema and test data02_set_vars.sql: endpoint and key setup03_start_workflow.sql: workflow definition and kickoff04_verify.sql: result inspection queries
Notes
The implementation should explicitly parse df.http() response envelope fields before reading response body content.