Reputation: 225
I'm currently developing a function app using Microsoft's Azure functions in Visual Studio. I am able to deploy and publish the functions on azure and it seems to run but whenever I try to run a function local the Hosting Environment is unable to find any "Jobs". I have included a picture below.
It must be stated that I was at some point able to deploy locally but I believe after some updates, I was unable to run my functions
The current version of Azure Function and Web Jobs Tools: 15.0.40424.0
I have tried to use Azure Functions V1 (.NET Frameworks) and Azure Functions V2 (.NET Core) when I create a new project but with unsuccessful results. I have also tried to create a new clean project, reinstall VS and also reset Windows in case of any strange setup.
Am I missing something and do I explicitly need state my functions somewhere such that the hosting environment can find them??
Hosting environment not finding any functions:
[6/20/2018 7:24:37 AM] Host configuration file read:
[6/20/2018 7:24:37 AM] {}
[6/20/2018 7:24:37 AM] Starting Host (HostId=2017noy-1005193785,
InstanceId=c8332a19-7eb3-4446-9b3e-4307f20a57bc, Version=2.0.11651.0,
ProcessId=15184, AppDomainId=1, Debug=False, ConsecutiveErrors=0,
StartupCount=1, FunctionsExtensionVersion=)
[6/20/2018 7:24:38 AM] Generating 0 job function(s)
[6/20/2018 7:24:38 AM] No job functions found. Try making your job classes
and methods public. If you're using binding extensions (e.g. ServiceBus,
Timers, etc.) make sure you've called the registration method for the
extension(s) in your startup code (e.g. config.UseServiceBus(),
config.UseTimers(), etc.).
Template Empty HTTPTrigger Function - Function1.cs:
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static IActionResult
Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route =
null)]HttpRequest req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = new StreamReader(req.Body).ReadToEnd();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query
string or in the request body");
}
}
}
CSPROJ File
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13"
/>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
}
}
Upvotes: 1
Views: 9705
Reputation: 154
I had a same issue but I have downgrade Microsoft.NET.Sdk.Functions
from version 3.0.11 to 3.0.10 and then start a program and it has shown all my functions in the console application once the program successfully runs I have upgraded to the previous function 3.0.11 it worked.
Upvotes: 2
Reputation: 17800
The function.json
file is generated after VS build. Check whether it's in a folder named after your function, under ~\bin\Debug\netstandard2.0
folder.
If you don't see the folder like Function1
(containing function.json
inside), you may have met the same problem my colleague has.
Didn't find the rout cause, VS just failed to generate function.json
on my colleagues's computer, but on my side things works fine(VS and Azure Function and Web Jobs Tools has the same version).
The workaround we found is to downgrade Microsoft.NET.Sdk.Functions
to 1.0.12
.
Just for your reference, we have also tried upgrading Azure Function and Web Jobs Tools
and delete Microsoft.NET.Sdk.Functions
in C:\Users\UserName\.nuget\packages\microsoft.net.sdk.functions\1.0.13
and install this package again.
Update
Upgrade Microsoft.NET.Sdk.Functions
to latest version of 1.0.14
also works on our side.
Upvotes: 3