Adding Content to an Azure Package

When using CloudServices in Windows Azure, you frequently want to add extra files to your package, such as startup scripts you want to register, or additional content that’s required.

Traditionally this has always been done by adding the file to the project, and setting the ‘Copy to Output Directory’ property to ‘Copy if Newer’. The file will now be included in the package.

There is another way. You can right click on your role in your Cloud Project, and add content or folders directly. Items added here will automatically be included in the package, with no need to adjust the file properties.

The 1.8 (October 2012) SDK release allows you to add a startup task here. Previous versions seemed to raise an error.

The advantage of adding content here is it separates our the Azure concerns from your project. You can use a single codebase for deploying an application on-premises, or in the cloud, without cluttering your project with script files that aren’t needed on-prem. It also stops you from forgetting to set the ‘Copy to Output Directory’ property!

Advertisements