You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在不删除已部署作业的前提下暂停Azure WebJob?

How to Temporarily Pause Azure WebJobs Without Deleting Them

Hey there, I totally get your frustration—having to delete and redeploy a WebJob just to pause it temporarily sounds like a huge hassle, and you’re right to question that approach. The good news is that modern Azure WebJobs have several built-in ways to pause/resume without losing your deployment. Here are the most practical methods:

1. Use Azure Portal Controls (Quickest for Manual Actions)

  • For Continuous WebJobs:
    Navigate to your WebJob in the Azure Portal, go to the Properties tab, and change the Run Mode from Continuous to On Demand. This will immediately stop the WebJob from running. To resume it, just switch the mode back to Continuous.
  • For Triggered WebJobs:
    • If it’s a schedule-based job (using CRON), you can temporarily update the CRON expression to a far-future time (like 0 0 1 1 1 * for once a year) to effectively pause it.
    • Alternatively, head to the Triggers section of your WebJob and manually disable the trigger. When you’re ready to resume, re-enable it.

2. Azure CLI Commands (Great for Automation or Scripting)

If you prefer using command-line tools, these commands let you pause and resume WebJobs in seconds:

  • Pause a continuous WebJob:
    az webapp webjob continuous stop --name <your-webjob-name> --resource-group <your-resource-group> --webapp-name <your-app-service-name>
    
  • Resume a continuous WebJob:
    az webapp webjob continuous start --name <your-webjob-name> --resource-group <your-resource-group> --webapp-name <your-app-service-name>
    
  • Disable a triggered WebJob:
    az webapp webjob triggered disable --name <your-webjob-name> --resource-group <your-resource-group> --webapp-name <your-app-service-name>
    
  • Enable a triggered WebJob:
    az webapp webjob triggered enable --name <your-webjob-name> --resource-group <your-resource-group> --webapp-name <your-app-service-name>
    

3. App Settings Toggle (No Code Changes Needed)

You can add a custom application setting to your App Service to control the WebJob’s execution:

  1. Go to your App Service in the Azure Portal → Configuration → Application settings.
  2. Add a new setting like WEBJOB_PAUSED with a value of true.
  3. Update your WebJob code to check for this setting at startup—if it’s true, skip the core job logic (or exit immediately).
  4. To resume, just change the setting value to false (or delete it) and restart the WebJob.

This method is perfect if you want to keep the WebJob deployed but prevent it from running temporarily, without modifying or redeploying code.

4. Azure Automation Runbooks (Scheduled Pause/Resume)

If you need to pause the WebJob automatically for specific periods (e.g., every night for 8 hours), set up an Azure Automation Runbook:

  • Create a PowerShell or Python script that uses Azure’s management APIs to stop/start the WebJob.
  • Schedule the Runbook to execute at your desired times using a time trigger.

Why Old Forums Suggest Deleting?

Those recommendations are likely outdated—early versions of Azure WebJobs had limited pause/resume functionality, forcing users to delete and redeploy. But modern Azure has addressed this gap, so you don’t need to resort to that drastic step anymore.

内容的提问来源于stack exchange,提问作者ezycoder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 01:47:27