admin管理员组

文章数量:1026087

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.

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.

本文标签: cHow to start the azure function inside docker if I use a different entry pointStack Overflow