I'm hosting my ASP.NET MVC applications as Azure Cloud Service.
I encountered a problem deleting pictures, which uploaded by user, after new deployment.
Uploaded pictures are saving into the custom special folder WebProject/UserFiles/MedicalCenterImages
Below I've provided my project folder structure.
I've found and investigated several questions related to my
Avoid deleting folder on Web Publish
MSDeploy skip rules when using MSBuild PublishProfile with Visual Studio 2012
and figure out, that I should to add a SkipDelete rule on 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 don't fully understand which file I should to edit in my case? (MaxPatient.Web.csproj or MaxPatientCloudService.ccproj or any another file)
I always publishing my MaxPatientCloudService project.
I will be grateful for any help.
Thanks :)
Azure Cloud Service deployments typically (staging slot with a VIP swap to prod slot) create new virtual machines (VMs). You can only plan on content files in the actual MVC project to get deployed to the new VMs. User uploads won't survive a deployment. You need to store uploaded files in Azure BLOBs, database or use an Azure website instead of a Cloud Service.
Whenever you publish to Azure Cloud Service, new VM is created. If I want Azure not to delete a blank folder, I normally add a dummy file inside the folder.
Ideally, you want to punish to Staging. Then SWAP Staging with Production so that you can minimize the downtime of our site.
In addition, you need at least two instances in Azure Cloud Service. One instance cannot access folder inside other instances.
Uploaded pictures are saving into the custom special folder WebProject/UserFiles/MedicalCenterImages
For scenario, you need to save customer images in Blob Storage (or SQL Azure), so that all instances can read/write the image.
Note: when Azure recycles an instance (whatever reason), it creates a new VM from original uploaded package. Therefore, we should never save data inside the web server's folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With