0

I run an azure funciton locally inside a docker container using this base image:

mcr.microsoft.com/azure-functions/dotnet:3.0

When having a look at the docker files (here for example: https://github.com/Azure/azure-functions-docker/blob/dev/host/2.0/stretch/amd64/dotnet/dotnet.Dockerfile), I see the /azure-functions-host/Microsoft.Azure.WebJobs.Script.WebHost library invoked at startup. However, I couldn't find any option to stop the running azure function and re-start it without restarting the whole container, so my question is:

How can I restart an azure function inside a linux container without restarting the whole container?

Tobias von Falkenhayn
  • 1,355
  • 5
  • 26
  • 59
  • 1
    There does seem to be a route available to restart the host. See here (https://github.com/Azure/azure-functions-host/blob/38447cd390b7b66900685c4a15a1ad548a6d6f53/src/WebJobs.Script.WebHost/Controllers/HostController.cs#L236). You would have to figure out how to authenticate to it and invoke it. Out of curiousity, why not just restart the container? – Rick Rainey Aug 17 '21 at 17:33
  • Thanks very much for your answer. I could invoke this route and restart the service, I wasn't aware that these files were on github. Authentication I could do by following these methods https://github.com/Azure/azure-functions-host/issues/4147 I am working on some testing framework for azure functions in docker where I like to test different behaviors of our functions and don't want to restart the whole container all the time – Tobias von Falkenhayn Aug 18 '21 at 04:54

1 Answers1

0

By Using Docker you cannot restart the specific services. It can restart the container.

docker restart [OPTIONS] CONTAINER [CONTAINER...]

Instead of Docker you need to use Docker-Compose. It will give the option for restart the specific service.

 restart [options] [SERVICE...]

Options:

-t, --timeout TIMEOUT  Specify a shutdown timeout in seconds. (default: 10)

Docker Vs Docker Compose

To use the Docker Compose check here

Refer moving-docker-compose-containersets-around-between-hosts & azure-functions-express-running-azure-functions-locally-using-docker-compose

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15