Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a requirement that I have to use TEntity with the class. But Azure function not working when using Generics with class. It's not even showing on the console also. But If I remove TEntity from class declaration it's showing in the console. So is this not supported? or is there any workaround for this? I have searched on internet but found nothing related to this.

public static class DataFilesIngestJobs<TEntity>
{
    [FunctionName("IngestDataFilesScheduled")]
    public static async Task RunScheduleAsync(
        [TimerTrigger("%DataFiles:IngestJob:ScheduleExpressionTrigger%")] TimerInfo timer,
        ExecutionContext context,
        TraceWriter log)
    {
        await RunAsync(context, log);
    }

    [FunctionName("IngestDataFilesOnDemand")]
    public static async Task RunOnDemandAsync(
        [QueueTrigger("%DataFiles:IngestJob:OnDemandQueueNameTrigger%", Connection = "ConnectionStrings:BlobStorageAccount")] string queueItem,
        ExecutionContext context,
        TraceWriter log)
    {
        await RunAsync(context, log);
    }
}

Console output on removing TEntity from class.

Found the following functions: [3/21/2018 6:52:41 AM] MyCompany.MyProject.DataFilesIngestJobs.RunScheduleAsync [3/21/2018 6:52:41 AM] MyCompany.MyProject.DataFilesIngestJobs.RunOnDemandAsync

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
148 views
Welcome To Ask or Share your Answers For Others

1 Answer

WebJobs SDK explicitly discards generic types when searching for FunctionName attribute:

return type.IsClass
    && (!type.IsAbstract || type.IsSealed)
    && type.IsPublic
    && !type.ContainsGenericParameters;

see source code.

I guess that's because they wouldn't know which type to use as generic parameter when calling the function method.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...