Azure-functions-host: Function App (using Spring Cloud) - Application starts/initializes again when another endpoint in same function app is called

Created on 30 Sep 2020  路  7Comments  路  Source: Azure/azure-functions-host

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

  • AbstractSpringFunctionAdapterInitializer [pool-2-thread-2] Initializing: class com.example.DemoFunction
  • Started application in xxxx seconds
    then the subsequent calls to function1 does not have these log statements.
    But when I give a call to function2, both above statements appear again. That means the DemoFunction is getting initialized again and Spring Boot application restarts.

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

Investigative information

Please provide the following:

  • Timestamp:
  • Function App version: 3
  • Function App name: SBRestartTestDemo
  • Function name(s) (as appropriate): function1 and function2
  • Invocation ID:
  • Region: Central India

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

  • Programming language used - Java
  • Links to source - N/A
  • Bindings used - None
external

All 7 comments

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

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

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

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

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

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

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

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...

Was this page helpful?
0 / 5 - 0 ratings