使用Azure中的Web应用程序使用多个部署使Webjob单身 [英] Making a Webjob a singleton using multiple deployments using Web Apps in Azure

查看:73
本文介绍了使用Azure中的Web应用程序使用多个部署使Webjob单身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Azure WebApp,我知道可以通过将"is_singleton": true添加到WebJob settings.job文件中来使WebJob成为一个单例,这在例如单个WebApp部署中有3个实例的情况下非常有用.

With Azure WebApps I know I can make a WebJob a singleton by adding the "is_singleton": true to the WebJob settings.job file, and this works great if I have for example, 3 instances in a single WebApp deployment.

但是-如何发布到两个WebApp(用例,两个不同的区域),并使WebJob作为一个实例运行,并且只能在其中一个部署上运行.

However - how can I publish to two WebApps (use case, two different regions) and make the WebJob run as a singleton and only on one of the deployments.

期望行为的示例:

悉尼部署

  • 我的Singleton Webjob(正在运行)
  • 我的其他处理队列的WebJob(正在运行)

新加坡部署

  • 我的Singleton Webjob(没有运行,或者甚至没有部署?)
  • 我的其他处理队列的WebJob(正在运行)

我知道我可以登录到azure门户并在其中一个部署中禁用Web作业,但是我可以对Visual Studio中的发布配置文件进行转换或更改,以自动实现所需的行为吗?

I know I can log in to the azure portal and disable the web job in one of the deployments, but is there a transform or change I can make to my publish profiles in visual studio to achieve the desired behavior automatically?

我当前正在使用Visual Studio 2015进行部署.

I'm currently deploying with Visual Studio 2015.

推荐答案

从站点的角度来看,这些站点是两个完全独立的站点,因此它们中的webjob彼此独立.如果要使它们成为单例,则必须添加一些自定义逻辑.

From the point of view of the sites, those are two completely independent sites and so the webjobs in them will be independent of each other. If you want to make them a singleton you'll have to add some custom logic.

选项包括:

  1. 在两个站点之一中设置一个应用程序设置,并告诉webjob仅在设置了该设置后才执行
  2. 使用Azure blob存储创建一个锁定文件,而获得该锁定的webjob是唯一可以运行的文件(这使您的webjob可以故障转移到第二个区域,第一个失败)

这篇关于使用Azure中的Web应用程序使用多个部署使Webjob单身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆