11

I've got to a website and a webjob project in the same sln:

  • Sritt (The website)
  • Sritt.Webjob

In properties of Sritt theres a webjobs-list.json with the following setting:

"WebJobs": [
    {
      "filePath": "../Sritt.WebJob/Sritt.WebJob.csproj"
    }

I've configured the by VSTS build like this (with the new buildsystem):

Solution: **\*.sln    
MSBuild Args: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"

Building in VSTS gives me the following warning:

 C:\a\1\s\packages\Microsoft.Web.WebJobs.Publish.1.0.9\tools\webjobs.console.targets(149,5): warning : WebJob schedule for SrittWebJob will not be created. WebJob schedules can only be created when the publish destination is an Azure Website [C:\a\1\s\Sritt.WebJob\Sritt.WebJob.csproj]

And the following error:

packageFile= Find-Files -SearchPattern C:\a\1\a\**\*.zip
packageFile= C:\a\1\a\Sritt.WebJob.zip C:\a\1\a\Sritt.zip
Found more than one file to deploy with search pattern 'C:\a\1\a\**\*.zip'. There can be only one.  

How can I deploy both the website and the webjob? Do I need to split them into different solutions?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Larsi
  • 4,654
  • 7
  • 46
  • 75

2 Answers2

24

Seems you are using "Azure Web App Deployment" task to deploy the project. You don't need to split them into different solutions but you need to deploy them in separate tasks.

So you need to add one more "Azure Web App Deployment" task in you build definition. The setting is almost the same for these two tasks except the "Web Deploy Package" section: One is "$(build.artifactstagingdirectory)\**\Sritt.zip" and another one is "$(build.artifactstagingdirectory)\**\Sritt.WebJob.zip".

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • Thanks, that fixed the problem. Thanks also for taking the time to write out the actual settings to use :-) – Larsi Feb 17 '16 at 17:43
  • 1
    Hi again - this probably a new question, just in case it's easy: After deployment I'm unable to open the website, I get the yellow page, to turn debug on - but it's already on. Looks like the entire webpage goes down when I add webjob project. Removing the project and republish everythin works again. Any idea? – Larsi Feb 17 '16 at 21:27
  • @Larsi Can you open a new case to include more details like which project you removed, what page you get after deployment? – Eddie Chen - MSFT Feb 18 '16 at 03:43
  • 3
    @Larsi By the way, I forget to mention that if the webjobs is created and added to the project, you just need to deploy the project, the webjob should be deployed along with the project. – Eddie Chen - MSFT Feb 18 '16 at 06:27
  • deploying the website only removed that error, thanks. Btw, I just found out (the hard way) that there's no .net 4.6.1 support - any idea when that is coming? – Larsi Feb 18 '16 at 22:19
  • How do you know what the zip file will be called? – Demodave Jul 21 '17 at 20:42
  • @Demodave you can look under "Artifacts" from the Build details page after it's completed building. – jmdon Mar 06 '18 at 15:14
  • Isn't the issue just specifically naming the zipfile in the build definition? What I mean is, deploying Sritt.zip should automatically deploy the webjobs too (as listed in webjobs-list.json). The second task is just repeating the webjob deployment. At least, that's how it's working for me. – oflahero Mar 08 '18 at 12:10
  • EDIT: just saw Eddie's update above, sorry. Still - he's right though, the website deployment ought to automatically include the webjobs. Maybe it was a bug you were hitting two years ago that's fixed now :) – oflahero Mar 08 '18 at 12:16
1

The error is not related to the publishing of the WebJob, but to the publishing of the Azure Scheduler change. Generally, the Azure Schedule configuration from msbuild is known to have issues and is no longer recommended.

Instead, the suggested approach is to use the new WebJobs cron based schedule, which doesn't have those issues. See the docs for more details on setting this up (it's quite simple).

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thanks for looking into this. I'm running in "Shared" mode, the docs says cron only availible to Standard or Premium. I'm unsure of what you mean by "...but to the publishing of the Azure Scheduler change." Do you mean the "webjob-publish-settings.json"? – Larsi Feb 14 '16 at 18:59
  • It does require Basic or higher (doc says Standard or high but is incorrect), so it will not work in Shared mode. – David Ebbo Feb 15 '16 at 18:35
  • When using the Azure scheduler, the VS publishing process does two very different things. First, it publishing the Web Jobs to Azure App Service. Second it configures the Azure Scheduler. My clarification was that the error you get relates to the Azure Scheduler part and not the WebJob part. – David Ebbo Feb 15 '16 at 18:36