App Service和Webjob之间的共享锁 [英] Shared lock between App Service and Webjob
问题描述
我想在Webjob和App Service代码之间拥有一个共享锁.我已经尝试过在C#中使用lock关键字和互斥锁,但是它们似乎不起作用.我能想到的另一种选择是Blob租约,它也是用于在Webjobs环境中进行锁定的锁定机制,如
I want to have a shared lock between the Webjob and the App Service code. I have tried lock keyword as well as mutex in C# but they don't seem to be working. Another alternative I could think of is Blob lease which is also the locking mechanism used for locking within webjobs environments as written here.
azure webjobs是否在与App Service完全不同的环境中运行,以致共享锁不起作用,或者我丢失了某些东西?还有其他方法吗?
Do azure webjobs run in a totally separate environments from the App Service such that the shared locks are not working, or am I missing something ? Is there any other way ?
推荐答案
WebJobs在单独的进程中运行,因此C#中的lock
将不起作用.
WebJobs run in a separate process so a lock
in C# will not work.
在Blob上租用是进行分布式锁定的一种方法.这是一篇可以为您指出正确方向的文章: https://medium.com/veyotech/using-an-azure-lease-blob-as-a-distributed-mutex-a9608c918801
Lease on a blob is one way to make a distributed lock. Here is one article which can point you in the right direction with that: https://medium.com/veyotech/using-an-azure-lease-blob-as-a-distributed-mutex-a9608c918801
这篇关于App Service和Webjob之间的共享锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!