将Web应用程序发布到Azure网站登台部署插槽失败,并显示webjob

时间:2015-11-03 19:48:49

标签: asp.net visual-studio azure azure-webjobs azure-deployment-slots

我刚刚为我的应用创建了一个新的部署插槽,将发布配置文件导入Visual Studio,但部署后我收到以下错误消息:

  

错误8:创建WebJob计划时发生错误:找不到与提供的WebSiteName [myapp__staging]和WebSiteUrl [http://myapp-staging.azurewebsites.net]匹配的网站。

我有2个webjobs,一个连续的和预定的webjob。

我已经登录了正确的Azure帐户,如this answer所述。

我是否需要设置其他内容才能将我的应用部署到带有webjobs的暂存部署插槽?

我的应用程序正在使用ASP.NET,如果它有所作为?

2 个答案:

答案 0 :(得分:5)

使用Azure Scheduler时有一些怪癖。建议使用新的CRON支持。您可以详细了解herehere

答案 1 :(得分:3)

杰夫,

正如David建议的那样,您可以/应该迁移到新的CRON支持。这是一个例子。 WebJob将部署为连续的WebJob。

请记住,为了使用它,您需要安装当前是预发行版的WebJobs包和扩展。你可以在Nuget上获得它们。

  

安装包Microsoft.Azure.WebJobs -Pre   安装包Microsoft.Azure.WebJobs.Extensions -Pre

另外,正如David建议的那样,如果您不使用WebJobs SDK,也可以使用 settings.job 文件运行它。他提供了一个例子here.

<强> Program.cs的

static void Main()
{
    //Set up DI (In case you're using an IOC container)
    var module = new CustomModule();
    var kernel = new StandardKernel(module);

    //Configure JobHost
    var storageConnectionString = "your_connection_string";
    var config = new JobHostConfiguration(storageConnectionString) { JobActivator = new JobActivator(kernel) };
    config.UseTimers(); //Use this to use the CRON expression.

    //Pass configuration to JobJost
    var host = new JobHost(config);
    // The following code ensures that the WebJob will be running continuously
    host.RunAndBlock();
}

<强> Function.cs

public class Functions
{
    public void YourMethodName([TimerTrigger("00:05:00")] TimerInfo timerInfo, TextWriter log)
    {
        //This Job runs every 5 minutes. 
        //Do work here. 
    }
}

您可以在 TimerTrigger 属性中更改计划。

更新添加了webjob-publish-settings.json文件

这是webjob-publiss-settings.json

的一个例子
{
  "$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
  "webJobName": "YourWebJobName",
  "startTime": null,
  "endTime": null,
  "jobRecurrenceFrequency": null,
  "interval": null,
  "runMode": "Continuous"
}