Publish content files within an Azure Cloud Service project

711 Views Asked by At

I have Azure Cloud Service project that written in C#. This project is contain Azure Worker Role.

My Worker Role is reference another project (in same solution) that hold a directory in it. In this directory there are 10 HTML files. All those files are marked with those settings (file settings):

Build Action: Content

Copy to output directory: Copy if newer

I build my worker role and those content files are located on this path: bin/release/my-files/ dir. So, my project configuration is looking good.

I publish my azure cloud service to Azure, and the content files not being uploaded. I verified that by connecting with remote desktop to the machine and check this path: "E:\approot". my content files are not there.

What should I do in order to upload those content files?

Update

Thanks for @Gaurav_Mantri comment, I've check the CSSX file and my content files are missing there. No I not wondering that my azure worker role is missing too after publish.

I also tried to change "Copy to output directory -> Copy always". Same result.

2

There are 2 best solutions below

1
On

Not really an answer but one thing you may want to check if the files are included in the package itself. Essentially the package file (*.cspkg) is a zip file. What you can do is change the extension of the file from cspkg to zip and extract that file.

Once you extract the zip file, you will see files with cssx extension for each of your roles. Change the extension of those to zip as well and unzip those files.

If everything's configured well, you should be able to see those files in appropriate directory. If the files are not there, that means there's something wrong (obviously). What you could try in that case is change Copy to output directory to Copy Always instead of Copy if newer setting that you currently have.

2
On

General guidance is to avoid local file system interaction in cloud services and PaaS whenever possible, as (among other things) it requires you to duplicate your content on every VM in your solution (not necessarily a trivial task in the face of auto-scaling, etc.). You have a few options in Azure:

Azure Files let you interact with files and folders from a central location, as a network share:

Azure File Storage

You can always read and write files directly from Azure blobs:

Azure Blob storage

If your HTML content files are public facing and receive a more-than-small amount of traffic, you might also consider using the Azure CDN service to host them:

Azure CDN

Good luck!