简体   繁体   English

Azure 上的有状态和无服务器服务

[英]Stateful and serverless services on Azure

I am in the middle of a process, where I need to convert a bunch of old Windows services to a more cloud-friendly way of doing it.我正处于一个过程中,我需要将一堆旧的 Windows 服务转换为对云更友好的方式。 Right now, the only cloud in the solution, is that they are all hosted on a Azure Virtual Machine.目前,解决方案中唯一的云是它们都托管在 Azure 虚拟机上。 And, of cause, you are not able to scale a specific service, without scaling the whole Virtual Machine.而且,当然,如果不扩展整个虚拟机,您就无法扩展特定服务。

A lot of the services can, almost, be directly converted to Azure Functions, but others are stateful and eg requires a login procedure to an external part, before it can do its thing.许多服务几乎可以直接转换为 Azure Functions,但其他服务是有状态的,例如需要登录外部部分的程序,然后才能执行其操作。

What options do we have to create serverless services in Azure where state is required, or do I need to use technologies like Azure Worker Services or Azure Service Fabric?我们有哪些选项可以在需要状态的 Azure 中创建无服务器服务,或者我是否需要使用 Azure Worker Services 或 Azure Service Fabric 等技术?

Now I have a better understanding and I can provide some information.现在我有了更好的理解,我可以提供一些信息。

Worker Services (former Cloud Services) are not deprecated.工作人员服务(以前的云服务)没有被弃用。 You can either use Service Fabric or Virtual Machines as replacements.您可以使用 Service Fabric 或虚拟机作为替代。

You can easy scale Virtual Machines, using Virtual Machines Scale Sets but you'll need to write stateless services, or use a dedicated service as the 'state server' (For example, web applications that need a state server, you can use Azure Redis Cache for that).您可以使用虚拟机规模集轻松扩展虚拟机,但您需要编写无状态服务,或使用专用服务作为“状态服务器”(例如,需要状态服务器的 Web 应用程序,您可以使用 Azure Redis缓存)。

I usually rewrite my batch jobs as Azure Functions and I use Durable Functions whenever I can, as it simplify my functions code.我通常将批处理作业重写为 Azure Functions,并且我会尽可能使用 Durable Functions,因为它简化了我的函数代码。

Be aware, You can't use Durable Functions with .NET 5 at this moment.请注意,您目前无法在 .NET 5 中使用 Durable Functions。 It's not clear if it will be supported, or if they'll skip directly to .NET 6.目前尚不清楚它是否会得到支持,或者他们是否会直接跳到 .NET 6。

As another option, you can use a framework such as Hangfire and host on Azure App Service Plan (assuming you already have one).作为另一种选择,您可以使用 Hangfire 等框架并托管 Azure 应用服务计划(假设您已经拥有)。 It works great for long running processes and has a great dashboard where you can monitor the status of your jobs.它非常适合长时间运行的流程,并有一个很棒的仪表板,您可以在其中监控作业的状态。

You can also spinoff some Containers using Azure Container Instances and use it to process your jobs.您还可以使用 Azure 容器实例衍生一些容器并使用它来处理您的作业。

Now given all this information, the choice depends on your requirements.现在有了所有这些信息,选择取决于您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM