简体   繁体   English

在Azure中以编程方式创建Webjobs

[英]Create webjobs programmatically in Azure

We'll be providing our customers with an Admin section within our web app where they'll be allowed to set various admin related settings and one of the section we'd like to provide within the admin module is a front end that will allow an admin user to add/update/delete webjobs (predefined only) and schedule them to run every x minutes within a given range ie working week for example. 我们将在我们的网络应用程序中为客户提供一个“管理”部分,允许他们设置各种与管理相关的设置,我们希望在“管理”模块中提供的部分之一是前端,该前端将允许管理员用户可以添加/更新/删除网络作业(仅预定义),并安排它们在给定范围(例如工作周)内每x分钟运行一次。

There will only be a finite list of webjobs that we'll provide to our clients but we really don't want to hardcode the scheduling or having to set it up for them, so we really need to allow them to this via the admin module. 我们只会向客户提供一定数量的webjob,但我们确实不想硬编码计划或必须为其设置时间表,因此我们确实需要允许他们通过admin模块。

I don't mind using the REST API and while there seems to be a clear explanation on each of the Requests/Responses that are required from Create Job (Scheduler API) , but ideally, I'd prefer using the SDK and I'll continue researching it and see if I can find something but as I said, I don't seem to be able to find an example from start to finish. 我不介意使用REST API,尽管对于Create Job(Scheduler API)所需的每个请求/响应似乎都有清晰的解释,但理想情况下,我更喜欢使用SDK,并且我会继续研究它,看看是否能找到一些东西,但是正如我所说,我似乎无法从头到尾找到一个例子。

I'd appreciate if anyone could point me in the right direction and provide me the info I need trough a sample or provide me with a link or two to relevant articles. 如果有人能指出正确的方向并向我提供所需的信息,我将不胜感激,或者为我提供相关文章的一两个链接。

Thanks. 谢谢。

WebJobs deployment is nothing more than placing the WebJob files in the right place so it's quite easy to programmatically deploy a WebJob. WebJobs部署无非就是将WebJob文件放置在正确的位置,因此以编程方式部署WebJob相当容易。

Just place the files (or unzip a zip file) under d:\\home\\site\\wwwroot\\App_Data\\jobs\\{webjob type}\\{webjob name} 只需将文件(或解压缩zip文件)放在d:\\home\\site\\wwwroot\\App_Data\\jobs\\{webjob type}\\{webjob name}

Read more about this here . 在此处阅读有关此内容的更多信息。

Scheduling a WebJob (a triggered/ on demand one) programmatically is also easy once you don't use Azure Scheduler but use the internal scheduling that the WebJob core provides. 一旦使用Azure Scheduler,而是使用WebJob核心提供的内部调度,以编程方式计划WebJob(触发/按需计划)也很容易。

It is simply another file that describes the schedule, updating the file updates the schedule. 它只是描述时间表的另一个文件,更新文件将更新时间表。

See this question for more info or read more about the scheduling here . 有关更多信息,请参见此问题,或在此处阅读有关调度的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM