我的问题类似于下面的问题。
通知 NoAutomaticTrigger 类型作业的连续 Azure WebJob 何时停止
我使用了Amit 博客中的想法,但遇到了一点障碍
我在 webjob 中设置了一个文件观察程序,如果 webjob 从门户关闭,则会触发该文件观察程序。
在网络作业终止之前,我需要更新存储表中的一些标志。
问题是我的代码似乎停在我试图从存储表中检索记录的地方。我在以下代码周围有异常处理程序,并且控制台上没有写入异常消息。
下面是我的代码
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("my storage key");
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("myTable");
TableOperation operation = TableOperation.Retrieve("partKey", "rowKey");
var result = table.Execute(operation); // stucks here
if (result.Result != null)
{
MyEntity entity = (MyEntity)result.Result;
if (entity != null)
{
entity.IsRunning = false; //reset the flag
TableOperation update = TableOperation.InsertOrReplace(entity);
table.Execute(update); //update the record
}
}
我已将时间增加到stopping_wait_time
300settings.job
秒,但仍然没有运气。