I execute a very simple Function App to Docker
with this Dockerfile
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
namespace fapp1
{
public static class HttpIngress
{
[FunctionName("Health")]
public static IActionResult Health([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "health")] HttpRequest req) => new OkObjectResult("OK");
[FunctionName("HttpIngress")]
[return: ServiceBus("%queuename%", Connection = "servicebusconnection")]
public static async Task<string> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req)
=> await new StreamReader(req.Body).ReadToEndAsync();
}
}
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS installer-env
# Build requires 3.1 SDK
COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet
COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:4-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:4
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
docker run -it --env-file docker.env test
For both Functions in HttpIngress
I get this error:
fail: Host.Startup[0]
Error indexing method 'Health'
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method 'Health'
---> System.InvalidOperationException: Method overloads are not supported. There are multiple methods with the name 'fapp1.HttpIngress.Health'.
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndex.Add(IFunctionDefinition function, FunctionDescriptor descriptor, MethodInfo method) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndex.cs:line 30
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsyncCore(MethodInfo method, IFunctionIndexCollector index, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 349
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method, IFunctionIndexCollector index, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 149
--- End of inner exception stack trace ---
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo method, IFunctionIndexCollector index, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 157
at Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(Type type, IFunctionIndexCollector index, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 85
fail: Function.Health[0]
Microsoft.Azure.WebJobs.Host: Error indexing method 'Health'. Microsoft.Azure.WebJobs.Host: Method overloads are not supported. There are multiple methods with the name 'fapp1.HttpIngress.Health'.
warn: Host.Startup[0]
Function 'Health' failed indexing and will be disabled.
I tried
- changing from
static
class and methods to instance : no effect - putting each Function/method into separate classes : this worked, but this could merely be a work around
- switching
Microsoft.NET.Sdk.Functions
between4.0.1
(set by default onfunc init --worker-runtime dotnet --docker --language c#
) and current4.1.0
: no effect
I now run Functions in container for years but right now cannot figure out what I miss.
CodePudding user response:
I found your question as I had the same issue. It may have something to do with this:
https://github.com/Azure/azure-functions-host/issues/8244
Based on the info within the link I changed my dockerfile to use this image for azure functions:
FROM mcr.microsoft.com/azure-functions/dotnet:4.1.3-slim
This got it working for me