Windows Azure Website and static html in Blob storage

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 04:41:55

问题


So I have a .NET MVC app published in an Azure Website which should serve static html pages stored in a blob container when clicking on a corresponding hyperlink.

My questions are:

  1. The way to access a blob in Azure is https://blobtest.blob.core.windows.net/container/htmlpage1.html, however the peculiar part is when I login into my Azure Site and the url is something like: http://azuretestwebapp.azurewebsites.net/user123 and if I click on a hyperlink to my html blob it can't help but normally take me to blob azure site (well of course). Therefore I am wondering if there is a way to have a url similar to this: http://azuretestwebapp.azurewebsites.net/user123/container/htmlpage1.html considering that the html pages are stored elsewhere in Azure.
  2. If this is not feasible using an Azure Website or by storing static html pages in Blob, what would be a better approach?

Thank you in advance for your time.


回答1:


You can modify your web.config for your site to forward requests for static pages to blob storage using a redirect rule. Then the static content will be stored in and served from blob storage.

Place the following in a file named web.config (or modify your existing web.config) and put the web.config in the folder site/wwwroot on your website, next to the site content.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="static" stopProcessing="true">
          <match url="static/(.*)" />
          <action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />          
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>


来源:https://stackoverflow.com/questions/30842249/windows-azure-website-and-static-html-in-blob-storage

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