I have recently migrated from Azure Cloud Service to Azure Web App. Earlier I use to Disable the rapidFailProtection from my Webrole class. After the migration to Web App, I have remove the webrole class and added the code of rapidFail in the Application startup routine of the global.asax file. But it gave an error:
role discovery data is unavailable
at the following line:
Dim mainSite = serverManager.Sites(RoleEnvironment.CurrentRoleInstance.Id + "_Web")
How can I achieve the same functionality for my Azure Web App?
How can I achieve the same functionality for my Azure Web App?
As far as I know, the rapidFailProtection is a application pool setting which you could set it in the ApplicationHost.config file in app service.
So if you want to set the rapidFailProtection to false in the azure web app, I suggest you could try to use XML Document Transformation (XDT) declarations to transform the ApplicationHost.config file in your web app in Azure App Service.
I suggest you could try below steps to add the XDT file to your web app to change the ApplicationHost.config settings.
1.Access the KUDU console.Find the Advanced Tools in DEVELOPMENT TOOLS click go.
2.Click dubug console's cmd.
3.Locate the D:\home\site and add below xdt file.
Notice: Change the name as your web app service name
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<applicationPools>
<add name="testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='testforapppool')]/*[1])" />
</add>
<add name="~1testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='~1testforapppool')]/*[1])" />
</add>
</applicationPools>
</system.applicationHost>
</configuration>
Image:
Besides, you could also install Site Extension called IIS Manager which lets you very easily create XDT files simply by editing your applicationhost.config.
More details, you could refer to this article:
Azure App Service web app advanced config and extensions
Xdt transform samples
Related
I am trying to get our existing asp.NET core mvc app to run in an azure app service. Deployment works fine and all files i would expect are on the server.
Sadly, after trying to visit the url I am greeted by the message "You do not have permission to view this directory or page." which is the Statuscode 403.
The Log gives some more insight:
<div id="content"><div class="content-container"><h3>HTTP Error 403.14 - Forbidden</h3><h4>The Web server is configured to not list the contents of this directory.</h4></div><div class="content-container"><fieldset><h4>Most likely causes:</h4><ul> <li>A default document is not configured for the requested URL, and directory browsing is not enabled on the server.</li> </ul></fieldset></div><div class="content-container"><fieldset><h4>Things you can try:</h4><ul> <li>If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.</li> <li> Enable directory browsing using IIS Manager. <ol> <li>Open IIS Manager.</li> <li>In the Features view, double-click Directory Browsing.</li> <li>On the Directory Browsing page, in the Actions pane, click Enable.</li> </ol> </li> <li>Verify that the configuration/system.webServer/directoryBrowse#enabled attribute is set to true in the site or application configuration file.</li>
It seems like I am supposed to use some sort of landing page like index.html but that is not present for the given mvc Project.
I couldn't find any documentation for this configuration either. Even the youtube videos showcasing how easy it is to host a mvc app don't have to do any further configuration. (for example this one: watch)
I would be happy if anyone could tell me where I went wrong.
Thanks in advance,
Joshua
I have deployed a .NET Core MVC application over Azure App Service via Visual Studio and it worked. So, I notice that on this process, VS creates a web.config file. Once I remove it from App Service via Kudu, the application stopped.
So, the solution is to create a web.config file in the wwwroot folder on App Service environment. The content is like below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\My.Main.Project.dll"
stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
For the record, the application was created on .NET Core 3.1.
I am trying to deploy my Blazor WA to my local IIS, I have already deployed other .net core 3.1 API to another site locally. I have also successfully deployed the Blazor App to Azure Blob storage static website. From VS 2019 I click publish and it successfully publishes the file to the selected folder.
when I navigate to the url http://localhost:6989 I get 404 not found. I have followed the steps required from multiple locations
https://hostadvice.com/how-to/how-to-deploy-a-blazor-application-on-iis/
Here are the things I've changes in the site. not much has changed:
Web.cong settings:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
#LexLi Thanks for the comment. I used your comment to discover why my web.config was wrong. I had Some wrong versions of the assembles and I guess it wasn't acting nicely. I cleaned up the project and make sure I was using v3.2 and the web.config was generated properly
We’re building a web app (aspcore 3.0) published in app service.
This problem is that the mine type (json) is not recognized.
How to fix it ?
Thank you
It sounds like you were using Azure App Service on Windows to deploy your ASP.NET Core 3.0 application, but IIS on Azure WebApp can not set the response header Content-Type for JSON.
The reason is IIS on Azure WebApp default does not support static JSON file. To fix it, you need to change the web.config file to add the feature, as below.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
As reference, there is the other SO thread Getting "404 not found" on doing a GET on local file in Azure web app got the similar issue as yours and I answered it, please refer to it.
Is it possible to a custom configuration section inside of an Azure Cloud Service Configuration, the same way you would in a regular ASP.NET website?
I.e in a regular ASP.NET site your Web.Config would have something like this:
<configuration>
<configSections>
<section name="myCustomConfig" type="MyNamespace.MyType" />
</configSections>
<myCustomConfig someProperty="someValue" />
</configuration>
How is this done in Cloud Services and shared across multiple different roles?
At this time I do not believe this is possible. There is a post for it on user voice you can vote up: http://www.mygreatwindowsazureidea.com/forums/169386-cloud-services-web-and-worker-role-/suggestions/459944-enable-custom-configuration-sections-in-csdef-cscf.
As a way around this you could put configuration into a file that is stored in BLOB storage. On start up, or when it is needed, all instances could then go pull the file to get the configuration. To deal with changes to the configuration you could either have the instances pulling the configuration from time to time as a refresher, or you could tap into the environment changed event in RoleEntryPoint that is used to detect changes to the Service Configuration. Add a setting to the service configuration that is a version number of your shared config file or something, just anything that could be modified to trigger the RoleEnvironment.Changing event.
We have two asp.net web applications (Two asp web projects in one solution)
Both are hosted on IIS. Both apps expose WCF services.
Those services read and write files to the file system. In each service, we determine where to read and write files from using :
HttpContext.Current.Server.MapPath(".")
So in this way, each service writes and read from the folder of it's web app.
We want the services to read and write from the same place (We want this to happen in development and production ).
Is there a way to achieve this ?
Just an idea, define the same path in web.config of both web applications. Use the defined path instead of getting Server.MapPath(".").
web.config:
<configuration>
<appSettings>
<add key="Path" value="c:\\somefolder\\"/>
</appSettings>
</configuration>
C#:
ConfigurationManager.AppSettings["Path"]