web.config rewrite rule not working in Azure static website in blob storage web.config rewrite rule not working in Azure static website in blob storage azure azure

web.config rewrite rule not working in Azure static website in blob storage


You can do the deep linking if you point the 404 page back at your index.html. This is not a perfect solution - has side effects - but it will work for the majority of cases.

enter image description here


The static website in Azure Storage GPv2 is different from Azure App Service. It only hosts these static web files which include HTML/CSS/JavaScript files, other files can be handled in browser like images, robots.txt, etc. It has inability to process server-side scripts, due to there is not IIS. So your web.config file is no sense for it to change the access routing and be belong to server-side script for IIS.

Actually, you can see the words in Azure portal.

Configuring the blob service for static website hosting enables you to host static content in your storage account. Webpages may include static content and client-side scripts. Server-side scripting is not supported in Azure Storage. Learn more

And refer to the Learn more link of Static website hosting in Azure Storage

In contrast to static website hosting, dynamic sites that depend on server-side code are best hosted using Azure App Service.

I recommended using Azure App Service for your app if requires the URL-rewrite feature.


Although the accepted answer is right when it says that static websites don't process nicely the web.config, it is false that you cannot do what you want using a static website. Here's what you can do:

  1. Click on the 'Azure CDN' tag (below Static Website)
  2. Create a new CDN Profile (be careful to select the WEB (static website) link and not BLOB.
  3. Enter the newly CDN profile on 'All Resources'.
  4. Click on the single endpoint you see in 'Overview'.
  5. Click on 'Rules Engine'
  6. Add the following rule:

enter image description here

Credits: My answer is based on Andreas Wendl answer which you can find here (https://stackoverflow.com/a/59974770/3231884). I added some detail because after checking his answer it took me a couple of hours to understand exactly what I had to do.

There you go, you can now see perfectly the screen Andreas is speaking of