Venkat Kumar

Venkat Kumar

  • NA
  • 503
  • 140.2k

Retrieve the Status of the webjob after immediate run

Feb 27 2018 1:00 AM
I have written a code to run the Azure Webjob and the job ran successful. But I want to retrieve the Status(Success/Failed) of the webjob after immediate  run.
 
Webjob takes 5 mints to change the status from running to succees/fail.
  
Here is my code
 
//App Service Publish Profile Credentials
string userName = ConfigurationManager.AppSettings[envName + "UserName"];
string userPassword = ConfigurationManager.AppSettings[envName + "Password"];
 
var unEncodedString = String.Format($"{userName}:{userPassword}");
var encodedString = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(unEncodedString));
string URL = UrlToRunWebJob;
System.Net.WebRequest request = System.Net.WebRequest.Create(URL);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = 0;
request.Headers["Authorization"] = "Basic " + encodedString;
System.Net.WebResponse response = request.GetResponse(); //This line will execute the webjob
//
 Here I have to wait for 5 mints to get the status but It is stepping into the next line immediately.
// 
var responsetext = new StreamReader(response.GetResponseStream()).ReadToEnd(); 
 
Here responsetext is showing null. But I want the details of current executed webjob status.
 
Can someone help me on this issue?

Answers (1)