我在Azure门户上发布了一个持续WebJob,它执行一些任务。 我想在调用WebAPI时运行此WebJob,并且WebAPI不应该等待响应,它应该在后台运行WebJob。 我已经创建了一个WebAPI并尝试调用我的WebJob,但是它什么也没显示。
WebAPI WebJobController.cs代码:
public class WebJobController : ApiController
{
public void CallWebJob()
{
try
{
//App Service Publish Profile Credentials
string username = "userName"; //userName
string password = "userPWD"; //userPWD
string URL = "https://"+username+":"+password+"@reportjobprocess.scm.azurewebsites.net/api/continuouswebjobs/ContinuousReportServiceWebJob/run";
System.Net.WebRequest request = System.Net.WebRequest.Create(URL);
request.Method = "GET";
request.ContentLength = 0;
request.GetResponseAsync();
Console.WriteLine("OK"); //no response
}
catch (Exception ex)
{
Console.WriteLine("Something went wrong: " + ex.Message.ToString());
}
}
}
我对WebJob和WebAPI完全陌生。请帮忙。