Publishing web app to Azure Websites Staging deployment slot fails with webjob

I just created a new deployment slot for my app, imported the publishing profile to Visual Studio, but after deployment I get this error message:

Error 8: An error occurred while creating the WebJob schedule: No website could be found which matches the WebSiteName [myapp__staging] and WebSiteUrl [http://myapp-staging.azurewebsites.net] supplied.

I have 2 webjobs, a continuous and a scheduled webjob.

I already signed in to the correct Azure account, as stated by this answer.

Will I need to set something else up in order to deploy my app to a staging Deployment Slot with webjobs?

My app is using ASP.NET, if it makes a difference?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

There are a few quirks when using the Azure Scheduler. The recommendation is to use the new CRON support instead. You can learn more about it here and here.

Method 2

Jeff,

As David suggested, you can/should migrate to the new CRON support. Here’s an example. The WebJob will be deployed as a continuous WebJob.

Keep in mind that in order to use this you need to install the WebJobs package and extensions that are currently a prerelease. You can get them on Nuget.

Install-Package Microsoft.Azure.WebJobs -Pre
Install-Package Microsoft.Azure.WebJobs.Extensions -Pre

Also, as David suggested if you’re not using the WebJobs SDK, you can also run this using a settings.job file. He provided an example 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. 
    }
}

You can change the schedule in the TimerTrigger attribute.

UPDATE Added the webjob-publish-settings.json file

Here’s an example of the 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"
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x