Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy subfolders for Azure WebJob

I'm deploying a WebJob to Azure using Visual Studio, but none of the subdirectories in the build output folder of the project are copied to Azure (as per looking in the FTP folder and by virtue of the app not executing correctly). Is there any way to get the deploy to copy all the files and folders across?

More info: the subdirectories are from a referenced project and the files do have "Copy Always" set. They do appear in the output build directory of the WebJob project

UPDATE: So it seems that at some point this was fixed and now works as expected

like image 689
flipchart Avatar asked Nov 10 '14 09:11

flipchart


2 Answers

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!

like image 181
David Faivre Avatar answered Nov 16 '22 03:11

David Faivre


Thank you for reporting this. It looks like a bug in the tooling. I filed a bug for it.

like image 34
Victor Hurdugaci Avatar answered Nov 16 '22 04:11

Victor Hurdugaci