Reputation: 177
I have a Continuous WebJob published on my Azure Portal which performs some tasks. I want to run this WebJob on call of WebAPI & WebAPI should not wait for the response, it should run WebJob in the background. I have created one WebAPI & tried to call my WebJob but it is showing nothing.
WebAPI WebJobController.cs code:
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());
}
}
}
I'm totally new to WebJob & WebAPI. Please help.
Upvotes: 0
Views: 1539
Reputation: 14334
You could use WebJobs API to start/stop WebJob.
Start:wiki
POST /api/continuouswebjobs/{job name}/start
Stop:wiki
POST /api/continuouswebjobs/{job name}/stop
If you want to invoke triggered webjob you could use this. It doesn't support stop triggered job.
If you still have other questions, please let me know.
Update : about credentials you could refer to this.
Upvotes: 1