Azure Functions and Logic Apps integration from Business Central AL
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Note: In-process model deprecated Nov 2026. Use Isolated Worker (.NET 8+).
// Program.cs
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
// MyFunction.cs
[Function("MyFunction")]
public async Task<HttpResponseData> Run(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req)
{
var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteStringAsync("Result");
return response;
}Required in .csproj: <TargetFramework>net8.0</TargetFramework> + <OutputType>Exe</OutputType>
procedure CallAzureFunction(InputData: Text): Text
var
AzureFunction: Codeunit "Azure Functions";
AzureFunctionResponse: Codeunit "Azure Functions Response";
AzureFunctionAuth: Codeunit "Azure Functions Authentication";
IAzureFunctionAuth: Interface "Azure Functions Authentication";
ResponseText: Text;
begin
IAzureFunctionAuth := AzureFunctionAuth.CreateCodeAuth(GetFunctionUrl(), GetFunctionKey());
AzureFunctionResponse := AzureFunction.SendPostRequest(
IAzureFunctionAuth,
'{"data": "' + InputData + '"}',
'application/json');
if AzureFunctionResponse.IsSuccessful() then
AzureFunctionResponse.GetResultAsText(ResponseText)
else
Error('Azure Function failed: %1', AzureFunctionResponse.GetError());
exit(ResponseText);
end;
local procedure GetFunctionKey(): Text
var
FunctionKey: Text;
begin
if IsolatedStorage.Get('AzureFunctionKey', DataScope::Company, FunctionKey) then
exit(FunctionKey);
Error('Azure Function key not configured');
end;Common triggers:
When a Business Event occurs → React to BC eventsRecurrence → Scheduled data syncWhen file added to SharePoint → File processingBC Connector (GA 2024): Use Managed Identity for auth. Enable Run History for debugging.
| Method | Code | Use Case |
|---|---|---|
| Function Key | CreateCodeAuth(url, key) | Simple scenarios |
| Azure AD | CreateOAuth2(url, ...) | Enterprise |
| Managed Identity | Via Azure AD | Logic Apps |
if AzureFunctionResponse.IsSuccessful() then begin
AzureFunctionResponse.GetResultAsStream(ResultInStream);
DownloadFromStream(ResultInStream, 'Download', '', '', FileName);
end;| Plan | Cold Start | Best For |
|---|---|---|
| Consumption | Yes | Sporadic |
| Flex Consumption | Optional | Production |
| Premium | No | High-frequency |
Security: Never hardcode function keys → Isolated Storage. Use Azure AD for production.
Telemetry: Add to Program.cs for unified BC + Functions monitoring:
.ConfigureServices(services => {
services.AddApplicationInsightsTelemetryWorkerService();
})See references/ folder for:
azure-functions-patterns.md - Complete .NET examples