如何使用VSCODE中的Teams Toolkit在现有团队应用程序中添加新的可辩论后端?

发布于 2025-02-03 12:46:46 字数 4185 浏览 4 评论 0原文

我生成了一个具有前端和机器人功能的新团队应用程序。

现在,我将添加一个后端来管理服务器逻辑。

我不会在机器人应用程序中这样做。

因此,我使用团队工具包添加新功能:

”添加新功能“

逻辑上我选择了Azure函数,因为我可以使用工具包工具部署所有我的应用程序组件。

现在,在我的项目目录中,我拥有sub-app:

”

我的问题是:

  • 如何将此后端应用程序包含到abound.json.jsontasks.json为了使其作为bot和前线的辩论 结尾 ?
    //launch.json
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Launch Remote (Edge)",
                "type": "pwa-msedge",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "presentation": {
                    "group": "remote",
                    "order": 2
                }
            },
            {
                "name": "Launch Remote (Chrome)",
                "type": "pwa-chrome",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "presentation": {
                    "group": "remote",
                    "order": 1
                }
            },
            {
                "name": "Attach to Frontend (Edge)",
                "type": "pwa-msedge",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "cascadeTerminateToConfigurations": [
                    "Attach to Backend",
                    "Attach to Bot"
                ],
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
            {
                "name": "Attach to Frontend (Chrome)",
                "type": "pwa-chrome",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "cascadeTerminateToConfigurations": [
                    "Attach to Backend",
                    "Attach to Bot"
                ],
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
            {
                "name": "Attach to Bot",
                "type": "pwa-node",
                "request": "attach",
                "port": 9239,
                "restart": true,
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
        ],
        "compounds": [
            {
                "name": "Debug (Edge)",
                "configurations": [
                    "Attach to Frontend (Edge)",
                    "Attach to Bot",
                ],
                "preLaunchTask": "Pre Debug Check & Start All",
                "presentation": {
                    "group": "all",
                    "order": 2
                },
                "stopAll": true
            },
            {
                "name": "Debug (Chrome)",
                "configurations": [
                    "Attach to Frontend (Chrome)",
                    "Attach to Bot",
                ],
                "preLaunchTask": "Pre Debug Check & Start All",
                "presentation": {
                    "group": "all",
                    "order": 1
                },
                "stopAll": true
            }
        ]
    }
  • 如何直接从工具包部署中部署它 工具

应用程序“

I generated a new teams app that has a front end and bot features.

Now I would add a backend to manage server logic.

I would not do that in the bot app.

So I used teams toolkit to add new feature:

add new feature

Logically I have choosen azure functions, because I would be able to deploy all my app components using the toolkit tools.

Now in my project directory I have the the sub-app:

sub app added

My questions are :

  • How can I include this backend app to the launch.json and
    tasks.json in order to make it debuggable as the bot and the front
    end ?
    //launch.json
    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Launch Remote (Edge)",
                "type": "pwa-msedge",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "presentation": {
                    "group": "remote",
                    "order": 2
                }
            },
            {
                "name": "Launch Remote (Chrome)",
                "type": "pwa-chrome",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "presentation": {
                    "group": "remote",
                    "order": 1
                }
            },
            {
                "name": "Attach to Frontend (Edge)",
                "type": "pwa-msedge",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "cascadeTerminateToConfigurations": [
                    "Attach to Backend",
                    "Attach to Bot"
                ],
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
            {
                "name": "Attach to Frontend (Chrome)",
                "type": "pwa-chrome",
                "request": "launch",
                "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
                "cascadeTerminateToConfigurations": [
                    "Attach to Backend",
                    "Attach to Bot"
                ],
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
            {
                "name": "Attach to Bot",
                "type": "pwa-node",
                "request": "attach",
                "port": 9239,
                "restart": true,
                "presentation": {
                    "group": "all",
                    "hidden": true
                }
            },
        ],
        "compounds": [
            {
                "name": "Debug (Edge)",
                "configurations": [
                    "Attach to Frontend (Edge)",
                    "Attach to Bot",
                ],
                "preLaunchTask": "Pre Debug Check & Start All",
                "presentation": {
                    "group": "all",
                    "order": 2
                },
                "stopAll": true
            },
            {
                "name": "Debug (Chrome)",
                "configurations": [
                    "Attach to Frontend (Chrome)",
                    "Attach to Bot",
                ],
                "preLaunchTask": "Pre Debug Check & Start All",
                "presentation": {
                    "group": "all",
                    "order": 1
                },
                "stopAll": true
            }
        ]
    }
  • How to make it deployable also directly from the toolkit deployment
    tools

deploy app

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫儰鉨ミ守葔 2025-02-10 12:46:47

当Azure函数添加到项目中时,.vscode/laining.json.vscode/tasks.json应自动更新以支持Debug Azure函数。你的案子很奇怪。无论如何,您可以使用以下.vscode/abougn.json.vscode/tasks.json来调试您的应用程序。

// .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Remote (Edge)",
            "type": "pwa-msedge",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "presentation": {
                "group": "remote",
                "order": 1
            }
        },
        {
            "name": "Launch Remote (Chrome)",
            "type": "pwa-chrome",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "presentation": {
                "group": "remote",
                "order": 2
            }
        },
        {
            "name": "Attach to Frontend (Edge)",
            "type": "pwa-msedge",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "cascadeTerminateToConfigurations": [
                "Attach to Backend",
                "Attach to Bot"
            ],
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Frontend (Chrome)",
            "type": "pwa-chrome",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "cascadeTerminateToConfigurations": [
                "Attach to Backend",
                "Attach to Bot"
            ],
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Bot",
            "type": "pwa-node",
            "request": "attach",
            "port": 9239,
            "restart": true,
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Backend",
            "type": "pwa-node",
            "request": "attach",
            "port": 9229,
            "restart": true,
            "presentation": {
                "group": "all",
                "hidden": true
            },
            "internalConsoleOptions": "neverOpen"
        }
    ],
    "compounds": [
        {
            "name": "Debug (Edge)",
            "configurations": [
                "Attach to Frontend (Edge)",
                "Attach to Bot",
                "Attach to Backend"
            ],
            "preLaunchTask": "Pre Debug Check & Start All",
            "presentation": {
                "group": "all",
                "order": 1
            },
            "stopAll": true
        },
        {
            "name": "Debug (Chrome)",
            "configurations": [
                "Attach to Frontend (Chrome)",
                "Attach to Bot",
                "Attach to Backend"
            ],
            "preLaunchTask": "Pre Debug Check & Start All",
            "presentation": {
                "group": "all",
                "order": 2
            },
            "stopAll": true
        }
    ]
}

// .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Pre Debug Check & Start All",
            "dependsOn": [
                "validate local prerequisites",
                "start ngrok",
                "prepare local environment",
                "Start All"
            ],
            "dependsOrder": "sequence"
        },
        {
            "label": "validate local prerequisites",
            "type": "shell",
            "command": "exit ${command:fx-extension.validate-local-prerequisites}",
            "presentation": {
                "reveal": "never"
            }
        },
        {
            "label": "start ngrok",
            "dependsOn": "teamsfx: ngrok start"
        },
        {
            "label": "prepare local environment",
            "type": "shell",
            "command": "exit ${command:fx-extension.pre-debug-check}",
            "presentation": {
                "reveal": "never"
            }
        },
        {
            "label": "Start All",
            "dependsOn": [
                "Start Frontend",
                "Start Backend",
                "Start Bot"
            ]
        },
        {
            "label": "Start Frontend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-frontend-watch",
            "options": {
                "cwd": "${workspaceFolder}/tabs"
            }
        },
        {
            "label": "Start Backend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-backend-watch",
            "options": {
                "cwd": "${workspaceFolder}/api",
                "env": {
                    "PATH": "${command:fx-extension.get-func-path}${env:PATH}"
                }
            },
            "presentation": {
                "reveal": "silent"
            }
        },
        {
            "label": "Start Bot",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": {
                "pattern": [
                    {
                        "regexp": "^.*$",
                        "file": 0,
                        "location": 1,
                        "message": 2
                    }
                ],
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "[nodemon] starting",
                    "endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
                }
            },
            "options": {
                "cwd": "${workspaceFolder}/bot"
            },
            "presentation": {
                "reveal": "silent"
            }
        }
    ]
}

对于部署,请首先运行“在云中”,然后运行“部署到云”命令。

When Azure Functions is added to the project, .vscode/launch.json and .vscode/tasks.json should be updated automatically to support debug Azure Functions. Your case is strange. Anyway, you can use following .vscode/launch.json and .vscode/tasks.json to debug your app.

// .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Remote (Edge)",
            "type": "pwa-msedge",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "presentation": {
                "group": "remote",
                "order": 1
            }
        },
        {
            "name": "Launch Remote (Chrome)",
            "type": "pwa-chrome",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${teamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "presentation": {
                "group": "remote",
                "order": 2
            }
        },
        {
            "name": "Attach to Frontend (Edge)",
            "type": "pwa-msedge",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "cascadeTerminateToConfigurations": [
                "Attach to Backend",
                "Attach to Bot"
            ],
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Frontend (Chrome)",
            "type": "pwa-chrome",
            "request": "launch",
            "url": "https://teams.microsoft.com/l/app/${localTeamsAppId}?installAppPackage=true&webjoin=true&${account-hint}",
            "cascadeTerminateToConfigurations": [
                "Attach to Backend",
                "Attach to Bot"
            ],
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Bot",
            "type": "pwa-node",
            "request": "attach",
            "port": 9239,
            "restart": true,
            "presentation": {
                "group": "all",
                "hidden": true
            }
        },
        {
            "name": "Attach to Backend",
            "type": "pwa-node",
            "request": "attach",
            "port": 9229,
            "restart": true,
            "presentation": {
                "group": "all",
                "hidden": true
            },
            "internalConsoleOptions": "neverOpen"
        }
    ],
    "compounds": [
        {
            "name": "Debug (Edge)",
            "configurations": [
                "Attach to Frontend (Edge)",
                "Attach to Bot",
                "Attach to Backend"
            ],
            "preLaunchTask": "Pre Debug Check & Start All",
            "presentation": {
                "group": "all",
                "order": 1
            },
            "stopAll": true
        },
        {
            "name": "Debug (Chrome)",
            "configurations": [
                "Attach to Frontend (Chrome)",
                "Attach to Bot",
                "Attach to Backend"
            ],
            "preLaunchTask": "Pre Debug Check & Start All",
            "presentation": {
                "group": "all",
                "order": 2
            },
            "stopAll": true
        }
    ]
}

// .vscode/tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Pre Debug Check & Start All",
            "dependsOn": [
                "validate local prerequisites",
                "start ngrok",
                "prepare local environment",
                "Start All"
            ],
            "dependsOrder": "sequence"
        },
        {
            "label": "validate local prerequisites",
            "type": "shell",
            "command": "exit ${command:fx-extension.validate-local-prerequisites}",
            "presentation": {
                "reveal": "never"
            }
        },
        {
            "label": "start ngrok",
            "dependsOn": "teamsfx: ngrok start"
        },
        {
            "label": "prepare local environment",
            "type": "shell",
            "command": "exit ${command:fx-extension.pre-debug-check}",
            "presentation": {
                "reveal": "never"
            }
        },
        {
            "label": "Start All",
            "dependsOn": [
                "Start Frontend",
                "Start Backend",
                "Start Bot"
            ]
        },
        {
            "label": "Start Frontend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-frontend-watch",
            "options": {
                "cwd": "${workspaceFolder}/tabs"
            }
        },
        {
            "label": "Start Backend",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": "$teamsfx-backend-watch",
            "options": {
                "cwd": "${workspaceFolder}/api",
                "env": {
                    "PATH": "${command:fx-extension.get-func-path}${env:PATH}"
                }
            },
            "presentation": {
                "reveal": "silent"
            }
        },
        {
            "label": "Start Bot",
            "type": "shell",
            "command": "npm run dev:teamsfx",
            "isBackground": true,
            "problemMatcher": {
                "pattern": [
                    {
                        "regexp": "^.*
quot;,
                        "file": 0,
                        "location": 1,
                        "message": 2
                    }
                ],
                "background": {
                    "activeOnStart": true,
                    "beginsPattern": "[nodemon] starting",
                    "endsPattern": "restify listening to|Bot/ME service listening at|[nodemon] app crashed"
                }
            },
            "options": {
                "cwd": "${workspaceFolder}/bot"
            },
            "presentation": {
                "reveal": "silent"
            }
        }
    ]
}

For deployment, run "Provision in the cloud" first, and then run "Deploy to the cloud" command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文