31793

Stopping Website from within a WebJob

Is there any way of stopping an Azure website from a WebJob?

I have an Azure Website using Ghost that runs on Node. I'm trying to schedule a backup of the Ghost database file which ideally should be done while the site is not running. I can stop the site temporarily by terminating the Node.exe process using the Kudu PowerShell console.

If I try to do the same thing from a WebJob, the process does not get terminated - presumably because the WebJob is running in a different context and doesn't see the node.exe process.

Is there any way of stopping/starting a site from within a WebJob?

Answer1:

Azure web-sites are controlled via HTTP API. From your WebJob you can stop you web-site by issuing HTTP request. See here for details of the request.

However, WebJob is running in the same context as your Web-Site. So if the site is stopped, your WebJob will also be stopped. And you should have some other way to bring your site back online, because WebJob will not be there for you...

Answer2:

Actually it seems I was doing something wrong in my WebJob when I was originally trying to terminate the node.exe process.

While @trailmax is correct in that terminating the site (i.e. the w3wp process) will also stop the WebJobs (and indeed the Kudu site), you can terminate node.exe from a webjob. It will restart as soon as another connection is made to the site, so it's not the best solution unfortunately - unless some kind of async process is started to continually check for and terminate node.exe until the WebJob has finished its work.

Recommend

  • Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from dep
  • VS2008 XAML design view chokes on namespaced C++ assembly
  • Programmatically set Azure App Service application settings / environment variables
  • Can't add target for UIButton - unrecognised selector sent to instance, despite method been in
  • How do I run gulp.js in my asp.net core project when deploying to Azure using git?
  • Convert date string value from U.S. to native Date with current locale U.S.?
  • Find duplicate values in one of the two columns in a text file
  • C++, user input check for '\\0' stops at spaces?
  • Azure Resource Template Deployment issues
  • K Shortest Path Python Not Working
  • powershell: script to start a program with parameters?
  • In powershell, using the export-csv cmdlet, my ints are being encapsulated by quotes any idea why?
  • IIS 7.5 404 Error for .PDF files
  • Azure Diagnostic is not saving logs in azure tables
  • unrecognized selector isPitched called
  • Linux command line : edit hacked index files
  • c++ search a vector for element first seen position
  • Is there any purpose for h2-h6 headings in HTML5?
  • Most efficient way to move table rows from one table to another
  • Why are YouTube videos using 'youtube.com/v' not loading
  • How can I tell a form not to dispose a particular control when it closes?
  • aapt.exe'' finished with non-zero exit value 1
  • SonarQube: Cannot deactivate rule with missing quality profile
  • Web.config system.webserver errors
  • Tamper-proof configuration files in .NET?
  • Code in Job's Script Block after Start-Process Does not Execute
  • How can I sort a a table with VBA with given text condition?
  • iOS: Detect app start via notification press
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Highlight one bar in a series in highcharts?
  • formatting the colorbar ticklabels with SymLogNorm normalization in matplotlib
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Running a C# exe file
  • Trying to switch camera back to front but getting exception
  • Is there a mandatory requirement to switch app.yaml?
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Understanding cpu registers
  • How do I configure my settings file to work with unit tests?
  • UserPrincipal.Current returns apppool on IIS
  • How do I use LINQ to get all the Items that have a particular SubItem?