多个 Azure Web 作业
Multiple Azure Webjobs
我有这个 Azure 应用程序,我在其中托管 Webjob。
每当我启动该应用程序时,它只需 1 个 Webjob 即可正常运行,并且一切正常。但是随着时间的推移,突然出现了另一个 webjob,它是所需 webjob 的精确副本。
所以问题是当此功能未编码时会生成另一个 webjob(不需要的)。
请看图 1(必需/开始时的样子):
请看图 2(不需要/一段时间后发生):
这是一个触发式网络作业,其 cron 计划为 * * * * * *
。
So the problem is that another webjob (unwanted) is spawned when this
functionality is not coded in.
我假设你的情况是执行时间段造成的。请检查 doc 中的以下语句:
In Azure environment, the scheduled webjob will only run on one instance (or worker). This is achieved by using file lock mechanism while the webjob is running. If the webjob happens to run for a very short time, there could be a race condition (such as clock sku) to cause another instance to later start up on the same schedule (since it detects no lock). The workaround is to make sure the webjob run for a certain period of time (say at least 5 seconds assuming schedule interval is greater).
另外还有一个类似的案例供大家参考:
我有这个 Azure 应用程序,我在其中托管 Webjob。
每当我启动该应用程序时,它只需 1 个 Webjob 即可正常运行,并且一切正常。但是随着时间的推移,突然出现了另一个 webjob,它是所需 webjob 的精确副本。
所以问题是当此功能未编码时会生成另一个 webjob(不需要的)。
请看图 1(必需/开始时的样子):
请看图 2(不需要/一段时间后发生):
这是一个触发式网络作业,其 cron 计划为 * * * * * *
。
So the problem is that another webjob (unwanted) is spawned when this functionality is not coded in.
我假设你的情况是执行时间段造成的。请检查 doc 中的以下语句:
In Azure environment, the scheduled webjob will only run on one instance (or worker). This is achieved by using file lock mechanism while the webjob is running. If the webjob happens to run for a very short time, there could be a race condition (such as clock sku) to cause another instance to later start up on the same schedule (since it detects no lock). The workaround is to make sure the webjob run for a certain period of time (say at least 5 seconds assuming schedule interval is greater).
另外还有一个类似的案例供大家参考: