Reputation: 216
I am working with Python V2 Azure Function Apps with Visual Studio Code, this is an API project hence in the main folder, I have separate folders for specific sections of API. My project structure is as below -
UI-API-Project
|- commonmodules (submodule)
|- .vscode
|- tasks.json
|- launch.json
|- settings.json
|- extensions.json
|- DashboardAPIProject
|- function_app.py
|- host.json
|- local.settings.json
|- requirements.txt
|- UploadAPIProject
|- function_app.py
|- host.json
|- local.settings.json
|- requirements.txt
My configuration files contents are such -
{
"configurations": [
{
"name": "Attach to Dashboard,
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start",
}
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"dependsOn": "pip install (functions)",
"options": {
"cwd": "${workspaceRoot}"
}
},
{
"label": "pip install (functions)",
"type": "shell",
"osx": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"windows": {
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
},
"linux": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceRoot}"
}
}
]
}
settings.json
{
"azureFunctions.deploySubpath": "API.Dashboard",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.projectLanguageModel": 2,
"azureFunctions.projectSubpath": "API.Dashboard"
}
The problem I have is that when I specify a particular project in settings.json, only that debugs, not all endpoints from both projects are specified. Can anyone help me with a way where I can add both folders (& many more in upcoming days) without having to change config everytime & only one runs at a moment.
Upvotes: 0
Views: 448
Reputation: 6469
As per the documentation, it is recommended to add all the triggers of azure functions for v2 python programming model in function_app.py
file to reduce the complexity.
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"dependsOn": "pip install (functions)",
"options": {
"cwd": "${workspaceFolder}/${input:functionapp}"
}
},
{
"label": "pip install (functions)",
"type": "shell",
"osx": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"windows": {
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
},
"linux": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
},
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/${input:functionapp}"
}
}
],
"inputs": [
{
"id": "functionapp",
"description": "Which Function App?",
"type": "pickString",
"options": [
"DashboardAPIProject",
"UploadAPIProject"
]
}
]
}
References-
How to run/debug Azure Functions project in a sub-folder in VS Code? - Microsoft Q&A.
Upvotes: 0