Hello,
I'm encountering an issue with my Azure Functions project that's causing a persistent "No job functions found. Try making your job classes and methods public" error. Despite following the standard guidelines, the error persists. Here are the details:
- Azure Functions Core Tools Version: 4.0.5455 (64-bit)
- Function Runtime Version: 4.27.5.21554
The error occurs when running the function app locally and the full message is as follows:
[2023-12-25T14:17:48.218Z] Found /Users/username/Downloads/Programming/ProjectName/ProjectName.csproj. Using for user secrets file configuration.
[2023-12-25T14:17:49.193Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MealzNow.Core\MealzNow.Core.csproj" />
<ProjectReference Include="..\MealzNow.Services\MealzNow.Services.csproj" />
<ProjectReference Include="..\MealzNow.Db\MealzNow.Db.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
using MealzNow.Services;
using MealzNow.Db;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole();
});
var logger = loggerFactory.CreateLogger<Program>();
try
{
var config = new ConfigurationBuilder()
.AddJsonFile("local.settings.json", optional: true)
.AddEnvironmentVariables()
.Build();
var cosmosDbAccount = config.GetValue<string>("CosmosDb:Account")
var cosmosDbKey = config.GetValue<string>("CosmosDb:Key")
var cosmosDbDatabaseName = config.GetValue<string>("CosmosDb:DatabaseName")
var host = new HostBuilder()
.ConfigureServices((context, services) =>
{
services.AddDbContext<MealzNowDataBaseContext>(options =>
options.UseCosmos(cosmosDbAccount, cosmosDbKey, cosmosDbDatabaseName));
services.AddRepositories(config);
services.AddServices(config);
services.AddAutoMapper(typeof(Program));
}).ConfigureFunctionsWorkerDefaults()
.Build();
await host.RunAsync();
}
catch (Exception ex)
{
logger.LogCritical("JW: " + ex.Message);
}
using System.Net;
using System.Text.Json;
using MealzNow.Core.RequestModels;
using MealzNow.Services.Interfaces;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace MealzNow.MobApi
{
public class MealzNowMobAppApi
{
private readonly ILogger _logger;
private readonly IAppService _appService;
public MealzNowMobAppApi(ILoggerFactory loggerFactory, IAppService appService)
{
_logger = loggerFactory.CreateLogger<MealzNowMobAppApi>();
_appService = appService;
}
[Function(nameof(GetClientFranchises))]
public async Task<HttpResponseData> GetClientFranchises([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req)
{
_logger.LogInformation("Calling GetClientFranchises funtion");
var content = await new StreamReader(req.Body).ReadToEndAsync();
if (content == null)
return req.CreateResponse(HttpStatusCode.BadRequest);
var request = JsonConvert.DeserializeObject<CommonRequest>(content);
if (request == null)
return req.CreateResponse(HttpStatusCode.BadRequest);
if (request.Id == Guid.Empty)
return req.CreateResponse(HttpStatusCode.BadRequest);
var data = await _appService.GetClientFranchises(request.Id.Value);
var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(data);
return response;
}
<omitting screenshot image>