Azure Functions application that synchronizes customer data from Business Central to Mailchimp using change tracking.
- Automated customer synchronization every 5 minutes
- Change tracking for efficient delta syncing
- Email validation and filtering
- Service Principal and Managed Identity authentication
npm install
cp .env.example .envEdit .env with required variables:
# Mailchimp
MAILCHIMP_API_KEY=your_api_key
MAILCHIMP_SERVER_PREFIX=us1
MAILCHIMP_LIST_ID=your_list_id
# Business Central
BC_TENANT_ID=your_tenant_id
BC_ENVIRONMENT=Production
BC_COMPANY_ID=your_company_id
# Authentication
USE_MANAGED_IDENTITY=false
BC_CLIENT_ID=your_client_id
BC_CLIENT_SECRET=your_client_secretnpm run build
func azure functionapp publish <your-function-app-name>Configure application settings in Azure Portal with values from .env.
Timer-triggered function runs every 5 minutes:
- Query Business Central for customers modified since last check
- Filter customers with valid email addresses
- Sync to Mailchimp audience
| Business Central | Mailchimp |
|---|---|
| email_address | |
| displayName | FNAME, LNAME, COMPANY |
| phoneNumber | PHONE |
| addressLine1 | ADDRESS |
| city | CITY |
| state | STATE |
| postalCode | ZIP |
| country | COUNTRY |
| id | BCID |
| number | BCNUMBER |
View logs: Azure Portal > Function App > BCCustomerSync > Monitor
Key metrics:
- Execution frequency: Every 5 minutes
- Changes detected per run
- Sync success rate
No customers syncing
- Verify BC API credentials
- Check customers have email addresses
- Review function logs
Authentication errors
- Verify BC_TENANT_ID, BC_CLIENT_ID, BC_CLIENT_SECRET
- Confirm Azure AD permissions granted
- Check application registered in BC
Mailchimp errors
- Verify API key valid
- Confirm List ID correct
- Check merge fields exist in audience
MIT