我正在将 azure web 作业用于一个计划。我想将其设为按需格式,并希望在单击我的网站上的按钮后开始工作。有可能吗?
提前致谢。
最佳答案
您可以通过 WebJob API 触发 WebJob。 C# 代码包含在以下帖子中:
http://chriskirby.net/blog/running-your-azure-webjobs-with-the-kudu-api
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://mysiteslot.scm.azurewebsites.net/api/");
// the creds from my .publishsettings file
var byteArray = Encoding.ASCII.GetBytes("username:password");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
// POST to the run action for my job
var response = await client.PostAsync("triggeredwebjobs/moJobName/run", null)
这必须在服务器端完成,因为您不希望授权信息暴露在客户端。
关于azure - 如何从我的网站启动 Azure Web 作业?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37968496/