gpt4 book ai didi

azure - Spring boot 微服务(Rest Api)作为 azure function-Azure function +spring Rest 微服务

转载 作者:行者123 更新时间:2023-12-03 02:58:44 25 4
gpt4 key购买 nike

首先要说明的是,我完全了解 Azure 函数和无服务器概念以及 Azure 函数的 5 分钟最大超时限制。

If you want to run any jobs more than 10 minutes choose webjobs. Azure functions, runs only for 5 minutes by default, if your process exceeds 5 minutes, then azure function throws timeout exception. You can increase the timeout to 10 minutes in host.json.

问题:

我尝试构建以下架构以节省azure上的成本,并希望将Spring Rest微服务部署为azure功能。

enter image description here

我已经创建了演示 Java Azure 函数,并且运行良好。-Azure Java function -502-Bad Gateway

现在我想在 azure 函数内调用我的 API,并且还想使用我的 spring-boot jar(将 jar 上传到存储或任何其他位置)。

有人尝试过这个吗?Azure java 函数是否可以实现?

最佳答案

根据我所做的快速研究,我认为我们无法将 spring-boot-stater-web 项目部署到 Azure Function 中,我可能是错的。

无论如何,我们都同意这是不合适的。毕竟,Azure Function 的应用程序生命周期与 Tomcat 等应用程序服务器不同。所以它值得一个不同的编程模型。

我相信您可以稍微修改您的项目以使用 spring-cloud-starter-function-web。请引用以下示例。

https://github.com/spring-cloud/spring-cloud-function/tree/master/spring-cloud-function-samples/function-sample-azure

https://cloud.spring.io/spring-cloud-function/#quick-start

https://www.youtube.com/watch?v=DufUqOxlkGk

另一种方法是编写自己的自定义启动器并将其添加到 Azure 函数项目中。

https://www.baeldung.com/spring-boot-custom-starter

关于azure - Spring boot 微服务(Rest Api)作为 azure function-Azure function +spring Rest 微服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51012945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com