-
Notifications
You must be signed in to change notification settings - Fork 134
Multiple function projects
The Azure Functions extension for VS Code assumes you have one function project per workspace folder. This assumption affects actions such as "Create new function", "Debug", and "Deploy". You have the following two options to set up your projects for use with the Azure Functions extension.
Set azureFunctions.projectSubpath
to the subpath matching the default project you want to use. All actions mentioned above will automatically use this project going forward.
If you want to run or debug multiple function projects at the same time, use a multi-root workspace. First, create the multi-root workspace:
- Open a single project in VS Code.
- Select
File -> Add Folder to Workspace...
to add the second project. - Select
File -> Save Workspace As...
to create a*.code-workspace
file in the parent folder containing both projects.
Once you have your multi-root workspace, you need to configure your projects to run at the same time. Specifically, each project needs to run on a separate port so that there are no conflicts. Follow these steps or check out the sample commits for your language below:
-
Add a compound launch config to the *.code-workspace file. It should look like this:
{ "folders": [ { "path": "app1" }, { "path": "app2" } ], "settings": { "debug.internalConsoleOptions": "neverOpen" }, "launch": { "configurations": [], "compounds": [ { "name": "Attach to both apps", "configurations": [ "Attach to app1", "Attach to app2" ] } ] } }
-
Modify one project to use different ports.
- Debug port: If you are using a language that attaches to a debug port (as opposed to attaching to a process), change the port specified in your launch.json (The value doesn't really matter as long as it's different from the other project)
-
Func host port: For all languages, add
--port 7072
to thefunc: host start
task in your tasks.json. You may also need to add this in your launch.json. (Again, the port doesn't matter as long as it's different than the default value7071
used by your other project)
-
In the debug window, you can now select to run a single project or both projects at the same time:
Example commit per language: