Azure Function Not Auto-Reloading When Dockerized

Viewed 115

This repository contains all the code I will be referring to: https://github.com/milantimotijevic/serverless-tutorial-azure

I'm trying to setup a fully Dockerized localdev environment with Azure Functions and Azurite, however, Azure Functions do not get automatically reloaded when running in a docker container, even though the code is getting updated via docker volumes. It does reload if I run Azure Functions on the host machine, however.

Steps to reproduce (scenario where it DOES auto reload):

  1. Run "npm install" to install project dependencies
  2. Run "install -g azure-functions-core-tools@3 --unsafe-perm true" to install Azure Functions as a global package on the host machine
  3. Run "docker-compose up azurite" to only start Azurite (to enable queues, etc.)
  4. Run "npm start" to start Azure Functions on the host machine
  5. Edit MyQueueTrigger/index.js

Result: The terminal where you ran "npm start" will show that the "func" process is automatically restarted. Furthermore, if you make use of offline-resources/commands to create a queue and push a message into it, you will see that the changes are automatically applying.

Steps to reproduce (scenario where it DOESN'T auto reload):

  1. Run "docker-compose up" to start both services inside Docker containers
  2. Edit MyQueueTrigger/index.js

Expected: The terminal in which you ran "docker-compose up" should reflect a restart of the "func" process in the relevant container.

Actual: The process does not get restarted, even though the file is indeed getting changed. You can confirm this by SSHing into microservices-tutorial-azure and checking the file you changed - the change will be there (due to the docker volume).

My host machine is running Windows. I took the "recommended" image for the docker container. Anyone have any idea why the process refuses to restart when inside that container? Thanks in advance!

1 Answers

What you can do is rebuild the image after each change that will restart the azure function.

Right now, every time some changes happen in the code might not reflect as the image is not rebuild.

Please refer the following documentation.

Related