English 中文(简体)
Several azure functions in the same file. Do the non-relevant dependencies get deployed for other functions as well?
原标题:

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?

问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签