最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to start the azure function inside docker if I use a different entry point? - Stack Overflow

programmeradmin1浏览0评论

I'm currently setting up a docker image for my azure function (.NET 8, isolated) that looks like this:

FROM mcr.microsoft/dotnet/sdk:8.0 AS installer-env

ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["myfunction/myfunction.csproj", "myfunction/"]
COPY . .
RUN dotnet publish "./myfunction/myfunction.csproj" --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-appservice
FROM mcr.microsoft/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

COPY ["myfunction/entrypoint.sh", "."]
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

And it then triggers my script that look like this:

#!/bin/sh

STARTUP_TASKS=/app/startup_tasks.sh

# Check if the startup tasks script exists and is executable
if [ -f "$STARTUP_TASKS" ]; then
    echo "Running additional startup tasks"
    "$STARTUP_TASKS"
else
    echo "No additional startup tasks found, skipping"
fi

// How do I start the azure function here?

My script triggers fine, but the problem is that the Azure Function doesn’t start afterward, and I don’t know how to get it to start. With regular apps, I can run exec dotnet myfunction.dll, but when I try this here, it doesn’t seem to start correctly (I get gRPC errors). I’ve also tried commands like exec func start, but it tells me that "func" does not exist.

Does anyone know a way to start the Azure Function after using a different entry point?

I'm currently setting up a docker image for my azure function (.NET 8, isolated) that looks like this:

FROM mcr.microsoft/dotnet/sdk:8.0 AS installer-env

ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["myfunction/myfunction.csproj", "myfunction/"]
COPY . .
RUN dotnet publish "./myfunction/myfunction.csproj" --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-appservice
FROM mcr.microsoft/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

COPY ["myfunction/entrypoint.sh", "."]
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

And it then triggers my script that look like this:

#!/bin/sh

STARTUP_TASKS=/app/startup_tasks.sh

# Check if the startup tasks script exists and is executable
if [ -f "$STARTUP_TASKS" ]; then
    echo "Running additional startup tasks"
    "$STARTUP_TASKS"
else
    echo "No additional startup tasks found, skipping"
fi

// How do I start the azure function here?

My script triggers fine, but the problem is that the Azure Function doesn’t start afterward, and I don’t know how to get it to start. With regular apps, I can run exec dotnet myfunction.dll, but when I try this here, it doesn’t seem to start correctly (I get gRPC errors). I’ve also tried commands like exec func start, but it tells me that "func" does not exist.

Does anyone know a way to start the Azure Function after using a different entry point?

Share Improve this question asked Nov 18, 2024 at 13:49 MilleBMilleB 1,6103 gold badges22 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

I found a solution for this issue, and you can simply end your entrypoint script with the following:

exec /opt/startup/start_nonappservice.sh

This will start the Azure Function as normal after everything else.

发布评论

评论列表(0)

  1. 暂无评论