No job Functions found. inside my azure durable functions

john john Pter 110 Reputation points
2024-02-05T23:59:53.9+00:00

I am building a durable function using visual studio 2022 + .net 8.0 isolated. Currently the durable function contain a simple function to get the list info of 2 SharePoint lists, here what i have built so far:- ActivityFunction.cs:-

using Microsoft.Azure.WebJobs;
using PnP.Core.Model.SharePoint;
using PnP.Core.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;


namespace SPDashBoard
{
    public class ActivityFunctions
    {
        private readonly IPnPContextFactory pnpContextFactory;

        public ActivityFunctions(IPnPContextFactory pnpContextFactory)
        {
            this.pnpContextFactory = pnpContextFactory;
        }

        [FunctionName(nameof(GetListInfo))]
        public async Task<IListDetails> GetListInfo([ActivityTrigger] string input,ILogger log)
        {
            log.LogWarning("About to call GetListInfo activity!");
            using (var objPnPContext = await pnpContextFactory.CreateAsync("Default"))
            {
                IList lstTarget = await objPnPContext.Web.Lists.GetByTitleAsync(input, l => l.Title,
                    l => l.TemplateType, log => log.ItemCount);
                await Task.Delay(1000);
                return new IListDetails()
                {
                    Title = lstTarget.Title,
                    TemplateType = lstTarget.TemplateType.ToString(),
                    ItemCount = lstTarget.ItemCount
                };


            }
        

        }



    }
}

OrchestrationFunctions.cs:-

using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SPDashBoard
{
    public class OrchestratorFunctions
    {
        [FunctionName("GetListsDetailsChaining")]
        public async Task<List<IListDetails>> GetListsDetailsChaining(
            [Microsoft.Azure.WebJobs.Extensions.DurableTask.OrchestrationTrigger] IDurableOrchestrationContext context,ILogger log)
        {
            log = context.CreateReplaySafeLogger(log);
            string[] listArr = new string[] { "WorkOrders", "Technicians" };
            List<IListDetails> listDetails = new List<IListDetails>();
            foreach (var strList in listArr) 
            {
                IListDetails lstDetails = await context.CallActivityAsync<IListDetails>(nameof(ActivityFunctions.GetListInfo), strList);
                listDetails.Add(lstDetails);
            
            }
            return listDetails;



        }

    }
}

Functions.cs

using Microsoft.Azure.WebJobs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs.Extensions;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.Logging;


namespace SPDashBoard
{
    public static class Functions
    {

        [FunctionName("GetListsDetailsChaining_SchduleStart")]
        public static async Task<string> GetListsDetailsChaining_SchduleStart( [TimerTrigger("0 */5 * * * *")] TimerInfo myTimer,  //[TimerTrigger("0 0 0 * * *")] TimerInfo myTimer,
            [Microsoft.Azure.WebJobs.Extensions.DurableTask.DurableClient] IDurableOrchestrationClient starter,ILogger log)
        {
            string instanceId = string.Empty;
            log.LogWarning("Starting the http starter Function = GetListDetails");
            instanceId = await starter.StartNewAsync(nameof(OrchestratorFunctions.GetListsDetailsChaining), null);
            DurableOrchestrationStatus durableOrchestrationStatus = await starter.GetStatusAsync(instanceId);
            while (durableOrchestrationStatus.RuntimeStatus != OrchestrationRuntimeStatus.Completed)
            {
                await Task.Delay(200);
                durableOrchestrationStatus = await starter.GetStatusAsync(instanceId);


            }

            return "done";




        }



    }
}

Startup.cs:-

using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PnP.Core.Auth;
using System.Security.Cryptography.X509Certificates;

[assembly: FunctionsStartup(typeof(SPDashBoard.Startup))]
namespace SPDashBoard
{
    class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {

            var config = builder.GetContext().Configuration;
            var azureFunctionSettings = new AzureFunctionSettings();
            config.Bind(azureFunctionSettings);
            builder.Services.AddPnPCore(options =>
            {
                options.DisableTelemetry = true;
                var authProvider = new X509CertificateAuthenticationProvider(azureFunctionSettings.ClientId,
                    azureFunctionSettings.TenantId,
                    StoreName.My,
                    StoreLocation.CurrentUser,
                    azureFunctionSettings.CertificateThumbprint);
                options.DefaultAuthenticationProvider = authProvider;

                options.Sites.Add("Default", new PnP.Core.Services.Builder.Configuration.PnPCoreSiteOptions

                {
                    SiteUrl = azureFunctionSettings.SiteUrl,
                    AuthenticationProvider = authProvider


                });

            });

        }

    }
}

Program.cs

using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(services =>
    {
        services.AddApplicationInsightsTelemetryWorkerService();
        services.ConfigureFunctionsApplicationInsights();
    })
    .Build();

host.Run();

but when i run the visual studio project i got this message that "no job function found", as follow:- User's image

any advice? why my project did not understand the function i built to query the SharePoint lists?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,021 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,211 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,236 Reputation points Microsoft Employee
    2024-02-07T09:10:25.29+00:00

    Hello @john john Pter - Thanks for reaching out, and posting on the MS Q&A.

    If you are using Azure Functions in .NET 5 or higher with the isolated execution model, you need to replace your FunctionName with Function, otherwise, the function will not be detected.

    Moreover, with .net 8.0 isolated worker, there's no Startup class needed and you should be able to create the Host on your own and do configurations all within the Program.cs file

    I recommend starting with one of the official samples for .NET 8.0 and begin adding the Sharepoint dependencies and implementing the relevant operations. Also, it doesn't look like you've any HTTP triggers; will you be needing the ASP.NET Core integration? If not, try switching to ConfigureFunctionsWorkerDefaults() instead of ConfigureFunctionsWebApplication()

    Hope this helps. Feel free to tag me in the comments below if you have any follow-up questions ;)


    Please "Accept Answer" if the answer is helpful so that others in the community may benefit from your experience.

    0 comments No comments