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

无法启动Azure WebJob(连接字符串未找到),新手求助定时任务配置

Fixing "Missing Connection String" Error for Azure WebJobs TimerTrigger

Hey there! Let's work through this connection string issue you're hitting with your Azure WebJob. I’ve been in your shoes when I first started with WebJobs—this is a super common gotcha, so we’ll get you sorted out quickly.

Why This Happens

The TimerTrigger (and QueueTrigger too!) relies on Azure Storage to manage scheduling state, locks, and other background tasks. The WebJobs SDK automatically looks for a connection string named AzureWebJobsStorage by default. If this isn’t configured anywhere, the SDK throws that "missing connection string" error when trying to start up.

Step-by-Step Fixes

1. Add the Connection String to Your Local Configuration

Depending on your .NET version, update your configuration file:

  • For .NET Framework (App.config):
    Add the connection string to the <connectionStrings> section:

    <configuration>
      <connectionStrings>
        <!-- Replace with your actual storage account connection string -->
        <add name="AzureWebJobsStorage" 
             connectionString="DefaultEndpointsProtocol=https;AccountName=your-storage-account;AccountKey=your-storage-key;EndpointSuffix=core.windows.net" />
      </connectionStrings>
    </configuration>
    
  • For .NET Core/.NET 5+ (appsettings.json):
    Add it under the ConnectionStrings node:

    {
      "ConnectionStrings": {
        "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=your-storage-account;AccountKey=your-storage-key;EndpointSuffix=core.windows.net"
      }
    }
    

2. Get Your Valid Storage Connection String

To get the correct connection string:

  • Go to the Azure Portal, navigate to your Storage Account
  • On the left menu, select Access keys under "Security + networking"
  • Copy the Connection string from either key1 or key2 (both work)
  • Paste this into your configuration file in place of the placeholder text.

3. Deployed WebJob? Update App Service Configuration

If you’re deploying the WebJob to an Azure App Service, don’t forget to add the connection string there too:

  • Go to your App Service → Configuration → Connection strings
  • Click New connection string
  • Set the Name to AzureWebJobsStorage, paste your connection string, and set Type to Custom
  • Save the changes—this will restart your App Service and pick up the new configuration.

Quick Check: Your Timer Expression is Correct!

Just a quick note: your TimerTrigger("0 0 23 * * *") is spot-on—it will trigger exactly at 23:00 every day, so no issues there once the connection string is fixed.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:19:25