Here is how my Functions file looks like with several Azure functions in it:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Extensions.Sql;
using Core.Entities.SqlServer;
using ReplicaService.TriggerProcessors;
using CoreConstants = Core.Constants;
using Timelock.Core.Entities.SqlServer;
using Timelock.ReplicaService.TriggerProcessors;
namespace TriggerFunctions
{
public class TriggerFunctions
{
private readonly UserChangeProcessor _altUserChangeProcessor;
private readonly UserContractFieldChangeProcessor _altUserContractFieldChangeProcessor;
private readonly PilotAgencyChangeProcessor _altPilotAgencyChangeProcessor;
private readonly AgencyRuleChangeProcessor _altAgencyRuleChangeProcessor;
private readonly AgencyFlagChangeProcessor _agencyFlagChangeProcessor;
private readonly AlternateCalendarChangeProcessor _altAlternateCalendarChangeProcessor;
public TriggerFunctions(
UserChangeProcessor altUserChangeProcessor,
UserContractFieldChangeProcessor altUserContractFieldChangeProcessor,
PilotAgencyChangeProcessor altPilotAgencyChangeProcessor,
AgencyRuleChangeProcessor altAgencyRuleChangeProcessor,
AgencyFlagChangeProcessor agencyFlagChangeProcessor,
AlternateCalendarChangeProcessor altAlternateCalendarChangeProcessor)
{
_altUserChangeProcessor = altUserChangeProcessor;
_altUserContractFieldChangeProcessor = altUserContractFieldChangeProcessor;
_altPilotAgencyChangeProcessor = altPilotAgencyChangeProcessor;
_altAgencyRuleChangeProcessor = altAgencyRuleChangeProcessor;
_agencyFlagChangeProcessor = agencyFlagChangeProcessor;
_altAlternateCalendarChangeProcessor = altAlternateCalendarChangeProcessor;
}
[Function("UsersTrigger")]
public async Task UsersTrigger([SqlTrigger("dbo.Users", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<UserEntity>> changes, FunctionContext context)
{
await _altUserChangeProcessor.ProcessChange(changes);
}
[Function("UserContractFieldsTrigger")]
public async Task UserContractFieldsTrigger([SqlTrigger("dbo.UserContractFields", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<UserContractFieldEntity>> changes, FunctionContext context)
{
await _altUserContractFieldChangeProcessor.ProcessChange(changes);
}
[Function("AgencyFlagsTrigger")]
public async Task AgencyFlagsTrigger([SqlTrigger("dbo.AgencyFlags", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<AgencyFlagEntity>> changes, FunctionContext context)
{
await _agencyFlagChangeProcessor.ProcessChange(changes);
}
[Function("PilotAgenciesTrigger")]
public async Task PilotAgenciesTrigger([SqlTrigger("dbo.PilotAgencies", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<PilotAgencyEntity>> changes, FunctionContext context)
{
await _altPilotAgencyChangeProcessor.ProcessChange(changes);
}
[Function("AgencyRulesTrigger")]
public async Task AgencyRulesTrigger([SqlTrigger("dbo.AgencyRules", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<AgencyRuleEntity>> changes, FunctionContext context)
{
await _altAgencyRuleChangeProcessor.ProcessChange(changes);
}
[Function("AlternateCalendarTrigger")]
public async Task AlternateCalendarTrigger([SqlTrigger("dbo.AlternateCalendar", CoreConstants.AppSettingsConnectionStringKey)] IReadOnlyList<SqlChange<AlternateCalendarEntity>> changes, FunctionContext context)
{
await _altAlternateCalendarChangeProcessor.ProcessChange(changes);
}
}
}
As you can see the dependencies for each function are pretty much independent from each other. So when I deploy these functions to the same Azure Function app, does each function only bring relevant dependencies or all of them?
The reason for my question is because I need fast scaling, and as each dependency brings quite a bit if extra code internally, I want to make sure that only relevant code per function is deployed for each function.
And if this is not the correct approach, what would the right approach be to insure independent dependencies between functions?
I am using Azure V4 isolated SQL Trigger Functions (not that I think it matters)
Does anyone have an answer?