Dynamically update sitemap.xml in Azure webrole

↘锁芯ラ 提交于 2019-12-13 02:25:28

问题


I am moving my existing website to Azure. In azure webrole I have
1. Website at default port and
2. Service at another port lets say :8000

Now my website creates some dynamic pages and the requirement is to update the sitemap.xml with the new URLs. At development stage I am able to create and update the sitemap.xml file from service. But this is not possible on staging server.

I am unable to understand why is it happening.Can any one tell me about a solution where I can create a sitemap.xml file at the root folder of website from the Service?


回答1:


I would say you have far bigger issue than the sitemap.xml itself!

Working in an Azure WebRole you have an non-persistent storage. This is the price we all pay for the scalability/elasticity/resilience of the cloud. This means that if something happens to the hardware (bare metal) where your code runs, Azure will instantiate a new one on a new piece of metal and will deploy your original package. At that point all your dynamically generated pages are lost, because are not part of your original package.

For all the content your site generates/accepts from user uploads/etc you have to use Azure Blob storage to persist. Once you got your dynamic content in a blob storage you have couple of options to deliver it to end user:

  • ASP.NET Handler (ashx) which will read the blob content and re-stream(send) it back to the end user (I would not go for this);
  • Dynamically generate appropriate links to the content in the blob storage. Using Shared Access Signature if content is has to be protected and not available to everyone;
  • Using custom VirtualPath provider to make remote content (Azure Blob) looks like local for the end user.

And now you probably already guessed - the best way to have Sitemap.xml always up-to-date is use again ASP.NET Handler to dynamically generate its content. Of course using caching of some sort (may even be blob) to avoid expensive calls and object graphs upon each request to Sitemap.xml.



来源:https://stackoverflow.com/questions/19420758/dynamically-update-sitemap-xml-in-azure-webrole

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!