[英]Debugging locally service that accesses backend database
Our cloud-deployed app is composed of (simplified):我们的云部署应用程序由(简化)组成:
When developing the front-end, I can easily debug by running the front-end locally, and redirecting its back-end calls to the actual services, since their endpoint routes are public.在开发前端时,我可以通过在本地运行前端并将其后端调用重定向到实际服务来轻松调试,因为它们的端点路由是公共的。
However, I also want to debug back-end service code, together with the front-end.但是,我也想调试后端服务代码,和前端一起调试。 I can run back-end services locally, but they can't access the database, since the database doesn't have any publicly-accessible endpoint.
我可以在本地运行后端服务,但它们无法访问数据库,因为数据库没有任何可公开访问的端点。
Question: How can I conveniently develop the service code?问:如何方便的开发服务代码? I can think of these options:
我可以想到这些选项:
Tech details: For cloud we use CloudFoundry over AWS.技术细节:对于云,我们在 AWS 上使用 CloudFoundry。 My back-end services are written in C# + .NET core 5. Locally, we develop them using Visual Studio 2019 on Windows.
我的后端服务写在C# + .NET core 5,本地我们在Windows上用Visual Studio 2019开发。
For now, I managed to expose my database locally using an SSH tunnel.现在,我设法使用 SSH 隧道在本地公开了我的数据库。 Specifically, by running
cf ssh [AppName] -L [local_port]:[db_hostname]:[port]
, with [db_hostname]:[port]
taken from the app's configuration, taken by running cf env [AppName]
.具体来说,通过运行
cf ssh [AppName] -L [local_port]:[db_hostname]:[port]
,其中[db_hostname]:[port]
从应用程序的配置中获取,通过运行cf env [AppName]
获取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.