Deploying Azure Website and WebJob via GIT

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)

2014-02-18 12_37_56-New ASP.NET Project - WebsiteAndWebJob

Step 1:

File new ASP.NET Project (MVC no Auth for fewest files possible)

2014-02-18 12_40_38-Greenshot

Step 2:

Add two New Projects to the solution.

  1. A Class Library (Mine is called Models) to share code between the website and the Web Job.
  2. A Console Application Called WebJob1

Step 3:

Add Solution References to The Class Library from Website and WebJob

Step 4:

Edit the console app to have this code (for demo)

Step 5:

Right click on the WebJob1 Project and select properties.

Then in the properties window select Build and Output path.

2014-02-18 12_45_27-Greenshot

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)

Step 6:

Build the Console Application

Step 7:

Navigate to the website’s App_Data  Folder

2014-02-18 12_46_09-Greenshot

Click on the Show All Files (Hanselman’s “Don’t Lie to me Button”)

Step 8:

Select All the files in the Webjob1 folder

**I had to not select the .pdb files because it wouldn’t find them on deploy**

2014-02-18 13_06_57-Greenshot

Step 9:

Include them in the project

2014-02-18 12_46_36-Greenshot

Step 10:

Set the properties of the files as Content and Copy if Newer

2014-02-18 13_06_57-Greenshot

Step 11:

Save and Build everything

Step 12:

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

2014-02-18 13_01_08-Greenshot

Step 13:

Click on the Web Jobs Tab

2014-02-18 13_05_25-Greenshot

Hooray there it is!

Bonus :

Click on the Logs On the right of the webjob and you can see everything we Console.WriteLine


Sample Project Available Here :