Migration from Azure function in-process model to isolated model

Paul D'hertoghe 20 Reputation points
2023-11-08T13:34:30.12+00:00

I migrated a project from Azure function in-process model to isolated model.

One of the activity functions in the in-process model had the signature:

        [FunctionName(nameof(GetImportProfiles))]
        public async Task<IEnumerable<ImportProfile>> GetImportProfiles(
            [ActivityTrigger] ILogger log)
        {
            return await _importProfilesRepository.GetProfiles();
        }

In the isolated process model it is recommended that an ILogger<T> is injected using the constructor, hence s activity was changed into:

        [Function(nameof(GetImportProfiles))]
        public async Task<IEnumerable<ImportProfile>> GetImportProfiles()
        {
            return await _importProfilesRepository.GetProfiles();
        }

When starting the function app, the following error is produced (also, none of the other Azure fuctions are found/listed):

[2023-11-08T13:30:42.167Z] A host error has occurred during startup operation '9185de92-32d5-4543-aa35-fdf1a58f2f78'.

[2023-11-08T13:30:42.167Z] Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader: At least one binding must be declared.

[2023-11-08T13:30:42.176Z] Failed to stop host instance '4c48a5dc-7c79-4c89-ae8b-3b8be6b401b8'.

[2023-11-08T13:30:42.176Z] Microsoft.Azure.WebJobs.Host: The host has not yet started.

Value cannot be null. (Parameter 'provider')

When changing the signature into the following:

        [Function(nameof(GetImportProfiles))]
        public async Task<IEnumerable<ImportProfile>> GetImportProfiles([ActivityTrigger] string dummy)
        {
            return await _importProfilesRepository.GetProfiles();
        }

it works again, can someone explain? Are activity functions without arguments not supported?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,192 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,108 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael McKechney 85 Reputation points Microsoft Employee
    2023-11-09T18:37:41.9066667+00:00

    You can declare an Activity function without a custom prarameter that needs to be passed and instead include FunctionContext so that gets passed in by injection.

    [Function(nameof(GetImportProfiles))]
    public async Task<IEnumerable<ImportProfile>> GetImportProfiles([ActivityTrigger] FunctionContext context)
    {
       return await _importProfilesRepository.GetProfiles();
    }
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.