【发布时间】:2015-12-07 20:18:30
【问题描述】:
我是 Azure WJ 的新手。 我在一个解决方案中有 2 个项目:实际的网站 - 项目 2 和 WebJob - 项目 1。 WJ 的唯一任务是在预定时间内从 project 2 的公共类中调用公开的方法。
创建 WJ 时,项目 2 - 网站 的类和方法被添加为 解决方案参考 到 项目 1 - WebJob 使它们易于访问。
我遇到的问题是:
构建 WebJob 时,它会在给定时间编译所有依赖项。当最终的 .zip 上传到 Azure WebJob 门户时,Webjob 将使用已编译的代码版本执行。这意味着在使用更新的 Project 2 - website 依赖项和 .zip 重新构建 WJ 之前,对 Project 2 - website 的任何新更改都不会生效已上传。
有没有办法创建 WJ(作为项目 1),只要调用的方法是在场吗?
例子:
WebJob 代码(项目 1):
namespace SecondProject
{
class Program
{
static void Main()
{
var client = new WebClient();
secondProjectMethod();
}
}
}
网站代码(项目 2):
namespace firstProject
{
public class someClass
{
public void secondProjectMethod()
{
// I want to make any code changes I want inside this
// method anytime and the WbJob should not care
// about these changes as long as this method name exist.
// Because all it should care about is that it should
// call this method name.
}
}
}
【问题讨论】:
-
由于您使用的是网站,因此您可以将 Proj2 中的方法公开为 API,并让 WebJob 以您计划的时间间隔调用 API(而不是方法)。所以即使你在Proj2中改变了方法,只要暴露的API调用更新的方法,WebJob就会独立。
-
是的,这似乎是最合乎逻辑的解决方案。我希望有更多可用的 API 代码示例。谢谢。
标签: c# azure-web-app-service azure-webjobs webjob