I want to start out saying this:
- Isn’t the best way
- Is a bad idea
- Is a random dude’s blog
- Is the way I do it as of today
So lets start Greenfield (you can modify for existing projects)
File new ASP.NET Project (MVC no Auth for fewest files possible)
Add two New Projects to the solution.
- A Class Library (Mine is called Models) to share code between the website and the Web Job.
- A Console Application Called WebJob1
Add Solution References to The Class Library from Website and WebJob
Edit the console app to have this code (for demo)
Right click on the WebJob1 Project and select properties.
Then in the properties window select Build and Output path.
Set the Path to :
jobs folder for all webjobs
continous means all full time (when the website is running)
then the name of the webjob (in our case WebJob1)
Build the Console Application
Navigate to the website’s App_Data Folder
Click on the Show All Files (Hanselman’s “Don’t Lie to me Button”)
Select All the files in the Webjob1 folder
**I had to not select the .pdb files because it wouldn’t find them on deploy**
Include them in the project
Set the properties of the files as Content and Copy if Newer
Save and Build everything
Git deploy to your website (you have it setup already, right? if not its a good time to)
Notice that nothing we’ve done up to this point is anything but set up a normal Azure website in the portal, and do git / github publishing
Click on the Web Jobs Tab
Hooray there it is!
Click on the Logs On the right of the webjob and you can see everything we Console.WriteLine
Sample Project Available Here : https://github.com/MarkKGreenway/WebsiteAndWebJob