Azure / Azure-Functions

1.11k stars 195 forks source link

Azure function restart when the root folder changes #2364

Open choprasaurav7 opened 1 year ago

choprasaurav7 commented 1 year ago

I want to use Azure functions to generate apps at runtime via CLI commands. Let's consider running angular generate command ng new hert. The process of new app creation internally involves creating new folders. As soon as the process starts creating new folders this in turn signals the function app to restart as the host configuration changes.

Please refer to the screenshot below :

image

Any help on this is appreciated.

To also include how I am executing the function:

  1. Using custom image over mcr base node image for az functions
  2. using HTTP trigger
  3. using node child process (spawn) to execute shell
vijaykumar911 commented 1 year ago

HI @choprasaurav7 will check and update you ...

vijaykumar911 commented 1 year ago

it seems like you are using Azure Functions with a custom image over the mcr base node image, and an HTTP trigger to execute a node child process to execute a shell command to create a new Angular app using the ng new command.

When you create new folders during the process of creating a new Angular app, it triggers a restart of the Azure Function app due to the host configuration changes.

To avoid this issue is to isolate the process of creating new folders outside of the Azure Function app runtime. You can achieve this by using Azure Blob Storage or Azure File Storage to store the new Angular app files, instead of creating the files directly on the local file system of the Azure Function app.

choprasaurav7 commented 1 year ago

@vijaykumar911 , Thank you for your response. Understood. But I would also like to understand if this restart because of the directory change is by design and why the restart is needed. Maybe you can help me with this. Is this happen because of some config in mcr base image?

Also, thanks for the suggestions on the alternatives. So if I understand you correctly, the script will be initiated on the Azure function but the write would happen on the blob storage? Is my understanding correct? Do you have an example to point me to?

choprasaurav7 commented 1 year ago

@vijaykumar911, is something needed from my side? I see the label added as needing author feedback.

niclascarlstedt commented 9 months ago

@vijaykumar911, Any updates on this question / issue?