简体   繁体   中英

Windows Azure Website and static html in Blob storage

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 ishttps://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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM