Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two processes of func reusing the same configuration settings #1414

Closed
borysl opened this issue Jun 28, 2019 · 6 comments
Closed

Two processes of func reusing the same configuration settings #1414

borysl opened this issue Jun 28, 2019 · 6 comments

Comments

@borysl
Copy link

borysl commented Jun 28, 2019

I am using v1 and I need to run two Function Apps locally with different settings and as the result different local.settings.json

As the result I have batch file like this:

start "Function App 1" /D ..\fa1 func host start run --port 7071 --nodeDebugPort 5858
start "Function App 2" /D ..\fa2 func host start run --port 7072 --nodeDebugPort 5859

however func.exe process uses the same properties from %AppData%\npm\node_modules\azure-functions-core-tools\bin\func.exe.Config
which means it will be overridden with local.settings.json from fa1 and fa2 in unclear order. Which is disaster.

Workaround can be that we load settings from local.settings.json in code, but in this case we actually provide different implementation from what we have in Azure Function themselves.

I also can have solution like this:

start "Function App 1" /D ..\fa1 func host start run --port 7071 --nodeDebugPort 5858
timeout 3 /nobreak
start "Function App 2" /D ..\fa2 func host start run --port 7072 --nodeDebugPort 5859

3 seconds is enough to load settings and then to let node replace the func.exe.Config with new one. However, in this case if functions will be recompiled they will receive different properties.

@ghost ghost added the Needs: Triage 🔍 label Jun 28, 2019
@fabiocav
Copy link
Member

fabiocav commented Jul 2, 2019

Can you elaborate on your scenario? are you actually using this to run production workloads, or is this while testing your functions?

The configuration mechanism supported today is local.settings.json, modifying the app config file is not a supported scenario.

@borysl
Copy link
Author

borysl commented Jul 3, 2019

I do not modify configuration in func.exe.config. Of course, I use local.settings.json.
I need to run integration test that involves two functional apps locally or in the MS Azure Pipeline. So I am running func host start two times.

The problem is that two func commands actually running the same process. Under the hood there is a node process and then the .Net Core func.exe process. As I have learned at a start local.settings.json are being integrated to func.exe.Config and then node starts func.exe which hosts the actuall function app.

it was designed to run exclusively one instance:

  • node process forms func.exe.Config
  • node process executes func.exe process
  • func.exe reads func.exe.Config

That is exactly the problem: func.exe.Config is unique for the machine, not the process, when I run two instances at the same moment, sometime it goes like this

  • node process A forms func.exe.Config
  • node process B forms func.exe.Config
  • node process A executes func.exe process
  • func.exe A reads func.exe.Config, but receive configuration from the function app B
  • node process B executes func.exe process
  • func.exe reads B func.exe.Config

@fabiocav
Copy link
Member

Apologies for the delayed response. For clarity, what Node process are you referring to above? Our Node boostrapper doesn't make any modifications to the func.exe.config file. Is this something you have setup?

Is this something you can provide repro steps for?

Thank you for all the additional information!

@ahmelsayed
Copy link
Contributor

in v1, the cli actually updates func.exe.config with the content of local.settings.json on startup (see this) This is because when running on Azure in v1 you expect to use ConfigurationManager.AppSettings and ConfigurationManager.ConnectionStrings but updating the ConfigurationManger object updates the .config file of the exe.

@fabiocav
Copy link
Member

thanks for the update @ahmelsayed ! I actually completely forgot that was the case, but now remember you bringing this up.

@borysl I'm not sure this is a fix we would target for V1. Would a move to V2 be an option for you? Another option would be to execute the CLI binaries from different locations, but that does require some work with your process. If the current workaround is working for you, I'd recommend keeping that until you have the ability to upgrade.

@lock
Copy link

lock bot commented Dec 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants