Avoid deleting files in Azure Cloud Service publish

I am hosting my ASP.NET MVC apps as Azure Cloud Service.

I am having a problem deleting snapshots that were uploaded by the user after a new deployment.

Downloaded photos are saved in a special dedicated folder WebProject/UserFiles/MedicalCenterImages

Below I have provided the project folder structure.

Project folder structure

I found and researched several questions related to my

and figure out that I have to add the SkipDelete rule to the .csproj file.

<Target Name="AddCustomSkipRules">
<Message Text="Adding Custom Skip Rules" />
<ItemGroup>
  <MsDeploySkipRules Include="SkipUserFilesFolder">
    <SkipAction>Delete</SkipAction>
    <ObjectName>filePath</ObjectName>
    <AbsolutePath>UserFiles</AbsolutePath>
  </MsDeploySkipRules>
</ItemGroup>
</Target>

      

but I am not quite clear what file do I need to change in my case? (MaxPatient.Web.csproj or MaxPatientCloudService.ccproj or any other file)

I always publish my MaxPatientCloudService project.

I would be grateful for any help.

Thank:)

+3


source to share


4 answers


Typically an Azure Cloud Service deployment (staging segment with VIP paging in the prod slot) creates new virtual machines (VMs). You can only schedule content files in the current MVC project to deploy to new virtual machines. Custom downloads won't survive. You need to save your uploaded files to an Azure BLOB, database, or use an Azure site instead of a cloud service.



+6


source


Whenever you publish to the Azure Cloud Service, a new virtual machine is created. If I want to prevent Azure from deleting an empty folder, I usually add a dummy file inside the folder.

Ideally, you want to punish Staging. Then SWAP Staging with Production allows us to minimize our website downtime.

Additionally, you need at least two instances in the Azure Cloud Service. One instance cannot access a folder inside other instances.



Uploaded photos are saved in a special special folder WebProject / UserFiles / MedicalCenterImages

For the scenario, you need to store customer images in Blob storage (or SQL Azure) so that all instances can read / write the image.

Note: When Azure recycles an instance (for whatever reason), it creates a new VM from the original downloaded package. Therefore, we should never save data inside web server folders.

+2


source


Go to "Publish Settings" → "Expand File Publish Options" → "And unbind the field that says to remove additional files at destination."

0


source


I'm not sure if this works for continuous deployment, but the manual deployment solution from VS is to put the server files you want to store in the App_Data folder.

The default publishing options for VS / Azure allow you to:

"Delete additional files at destination" and "Exclude files in the App_Data folder"

This means you can clean up redundant project files in a project without affecting files and data that are specific in a real application.

Potential downsides would be to restrict public access to App_Data and use the App_Data folder for general storage purposes - see also this post about this issue.

Images that are in the App_Data folder not visible in the browser

0


source







All Articles