I hacked together an automated deployment that seems to be work so far:
Add your WebJob project as a build dependency to your website project
I deploy my WebJob to a standalone Azure Website, so the website didn't reference the project directly. I don't want the build output of the WebJob project included in the bin of the website, just the proper app_data path. If you're not worried about MSBuild compatibility, you can set the build dependency using Visual Studio. Or you can edit the website project and add a reference with the other <Reference>
tags:
<ProjectReference Include="..\PathToJobs\Jobs.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
On PostBuild, copy the WebJob bin output to the magic app_data folder
WebJobs are expected to be in app_data\jobs\[type]\[name]
, so we copy the WebJob bin to the that folder in the website project:
set webjob_dist_path=$(ProjectDir)app_data\jobs\continuous\Job
IF EXIST "%webjob_dist_path%" (
RMDIR "%webjob_dist_path" /S /Q
)
XCOPY "$(SolutionDir)Jobs\bin\$(ConfigurationName)\*" "%webjob_dist_path" /Q /E /I /Y
Tell the website to include the WebJob magic folder when it deploys
(see: How do you include additional files using VS2010 web deployment packages?)
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="app_data\jobs\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>%(RelativeDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Deploy the website using the normal Azure Publish profiles. Done!