The Integration Challenge
Modern businesses rarely rely on a single application. Your ERP system needs to communicate with e-commerce platforms, CRM tools, payment gateways, and more. Business Central provides robust APIs, but connecting them directly to every external service quickly becomes unmanageable.
Azure Functions offer an elegant solution: a serverless compute layer that acts as middleware between Business Central and the outside world.
Why Azure Functions?
There are several reasons why Azure Functions are a great fit for Business Central integrations:
- Serverless — no infrastructure to manage, you only pay for what you use
- Event-driven — trigger functions from HTTP requests, timers, queues, or webhooks
- Native Azure AD integration — seamless authentication with Business Central APIs
- Scalable — automatically handles load spikes without configuration
- Multiple languages — write in C#, JavaScript, Python, or PowerShell
Architecture Overview
A typical integration pattern looks like this:
- An external system sends a webhook or event
- Azure Function receives the trigger and processes the payload
- The function authenticates with Business Central using OAuth 2.0
- Data is transformed and pushed to or pulled from BC via OData or API pages
- Results are returned or forwarded to the next service
This decoupled architecture means changes in one system don’t break others.
Setting Up Your First Integration Function
Let’s build a C# Azure Function that creates a Sales Order in Business Central when triggered by an HTTP request.
First, create a new Azure Functions project:
func init BCIntegration --dotnet
cd BCIntegration
func new --name CreateSalesOrder --template "HTTP trigger"Then configure your local.settings.json with Business Central credentials:
{
"Values": {
"BC_TENANT_ID": "your-tenant-id",
"BC_CLIENT_ID": "your-client-id",
"BC_CLIENT_SECRET": "your-client-secret",
"BC_ENVIRONMENT": "production",
"BC_COMPANY_ID": "your-company-id"
}
}Authentication with Business Central
Use the Microsoft Identity Client library to obtain an access token:
var app = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithClientSecret(clientSecret)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}")
.Build();
var result = await app.AcquireTokenForClient(
new[] { "https://api.businesscentral.dynamics.com/.default" })
.ExecuteAsync();With this token, you can make authenticated requests to the Business Central API.
Error Handling and Retry Logic
Production integrations must handle failures gracefully. Consider these practices:
- Use Azure Service Bus as a message queue for reliable delivery
- Implement exponential backoff when BC returns 429 (Too Many Requests)
- Log to Application Insights for monitoring and alerting
- Use Durable Functions for long-running orchestrations
Key Takeaways
- Azure Functions provide a scalable, cost-effective middleware layer for BC integrations
- OAuth 2.0 client credentials flow is the standard for service-to-service auth
- Always implement retry logic and dead-letter queues for production workloads
- Application Insights gives you full observability into your integration pipeline