我读过一些有关 Azure Durable Functions 的文章,但无论出于何种原因,我仍然没有完全体会到它的好处。
一篇文章提供了一个现实世界的例子:
Let’s say you’re selling airline tickets. You can imagine that as a person buys a ticket, we need to:
Check for the availability of the ticket. Make a request to get the seat map. Get their mileage points if they’re a loyalty member. Give them a mobile notification if the payment comes through and they have an app installed
我很欣赏这是一个具有多个异步等待的工作流程,但是标准 Azure 函数仅放置 API 调用并在继续之前等待结果有什么问题?
与标准函数相比,如果能够了解持久函数如何改进上述示例,那就太好了。
最佳答案
您已经可以在 MS 页面上找到(也许您已经这样做了)一些场景示例:
- https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-cloud-backup?tabs=csharp#scenario-overview
- https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor?tabs=csharp#scenario-overview
- https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor-python#scenario-overview
- https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-phone-verification?tabs=csharp#scenario-overview
根据自己的经验,我们使用持久功能主要是为了从某个点重新开始功能,例如功能(其阶段之一)失败。有了这个,我们可以“继续”来完成整个链,仅引用持久函数中的相同实体。当然,使用非持久功能也可以实现这一点,但不知何故需要额外的服务,例如服务总线。
关于azure - 了解耐用功能的实际好处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71103642/