I have an Angular application which I can deploy to Azure App Service without any issues.
First I compile my application using the following command:
ng build --output-path=dist --aot -prod
Then I add the following web.config
to the dist
folder:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<caching enabled="true" enableKernelCache="true">
<profiles>
<add extension=".js" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
I then zip the contents of the dist
folder up and drag it into my Azure application ( https://<site.scm.azurewebsites.net>/ZipDeploy
). At this point the app works fine.
My problem is that I would like to deploy different versions of the application for different locales.
I compile my different versions using the following commands:
ng build --output-path=dist/en --aot -prod --bh /en/ --i18n-format=xlf --locale=en
ng build --output-path=dist/fr --aot -prod --bh /fr/ --i18n-file=src/locale/messages.fr.xlf --i18n-format=xlf --locale=fr
This outputs the folders en
and fr
to /dist
containing the different versions of the app. I add a web.config
to each version of the app e.g inside /dist/en
and dist/fr
.
Next, I zip up the en & fr folders and deploy it using ZipDeploy
as above.
I can see my application homepage working fine at:
https://<site>.azurewebsites.net/en
https://<site>.azurewebsites.net/fr
However - when I get redirected to my application at https://<site>.azurewebsites.net/fr/redirect.html#state....
(I'm signing in using Azure B2C), I get the following error:
You do not have permission to view this directory or page.
This feels like iis is trying to literally interpret my url as a directory instead of letting Angular handle the routing but I'm not sure.
Does anybody know how to do this correctly?
en
andfr
folders are underD:\home\site\wwwroot
, you could leverage KUDU to check your deployed web contents. Based on your rewrite rule, since theen
andfr
is the folder, the url rewrite rule may not work, so I assumed that when accessinghttps://<site>.azurewebsites.net/en
, you should see theYou do not have permission to view this directory or page
error. – Carricohttps://<site>.azurewebsites.net/fr/redirect.html
could work as expected? – Carrico