Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 440 forks source link

Function App (using Spring Cloud) - Application starts/initializes again when another endpoint in same function app is called #6719

Open shashanksdixit opened 4 years ago

shashanksdixit commented 4 years ago

Description

I have created an function app [Java class com.example.DemoFunction], which has two functions namely function1 and function2. At the begining when function1 is called below is how the log messages are

If we keep switching between the function calls, the application initializes again.

Investigative information

Please provide the following:

Repro steps

Example:

  1. call https:///api/function1
  2. Azure function and Spring boot application initializes. (We can see the spring boot logo in the traces)
  3. call again https:///api/function1
  4. We do not see function initialized again, as expected. Response is quick.
  5. call https:///api/function2
  6. Azure function and Spring boot application initializes which is unexpected. (We can see the spring boot logo in the traces)
  7. call again https:///api/function2
  8. We do not see function initialized again, as expected. Response is quick.
  9. call https:///api/function1 again.
  10. Azure function and Spring boot application initializes again, which is unexpected.

Expected behavior

Once the function app is initialized then it should not get initialized for different function calls in it (unless it goes in cold state). One function app is initialized for function1 call, it should not get initialized again for function2 call.

Actual behavior

Function app is initialized for different function calls in it as given in the Example above.

Known workarounds

No workaround found.

Related information

Provide any related information

anthonychu commented 4 years ago

@shashanksdixit Do you have a simple app that reproduces this behavior?

@amamounelsayed @TsuyoshiUshio @apawast @anirudhgarg Is this something you can help look into?

shashanksdixit commented 4 years ago

I have uploaded the source code here. It is simple function app with two different functions.

TsuyoshiUshio commented 4 years ago

Thank you, @shashanksdixit . I'll have a look.

SelvamRajendrn commented 4 years ago

Any Update on this issue, I am also facing the same issue.

TsuyoshiUshio commented 3 years ago

Hi @shashanksdixit and @SelvamRajendrn ,

Sorry for late reply. I can reproduce it. I identify why it happens. It is happens inside of the spring-cloud-function. According to their code, they assume that it has one function. I'm not sure if it is a bug or limitation. So that I create an issue on their repo.

https://github.com/spring-cloud/spring-cloud-function/blob/a7104e489ec1f608dc7229b9faad12ca6eedf460/spring-cloud-function-adapters/spring-cloud-function-adapter-azure/src/main/java/org/springframework/cloud/function/adapter/azure/AzureSpringBootRequestHandler.java#L81

Issue

Could you watch this issue for the solution? https://github.com/spring-cloud/spring-cloud-function/issues/600

shashanksdixit commented 3 years ago

Hi @TsuyoshiUshio Thank you for your reply. Also thank you for creating the issue at Spring Cloud. I will watch that issue.

glauber-md commented 3 years ago

I have the same issue here... When I create a Java application for Azure Function Apps which has more than one function within, a new Spring Application is started for each function... In a scenario that I had 10 small functions, I got 10 Spring Applications started... for each one there was a Hikari pool starting and so on...