Path to App Service web.config in Post Deployment Action - azure-web-app-service

I have a dotnet core 3.1 app deployed to Azure App Service and I want to set the web.config's stdoutLogEnabled value to true once the deployment is complete. I've decided to do this using the Deploy Azure App Service step's inline Post Deployment Action.
The problem is that I don't know how to reference the web.config file in the correct location. What is the environment path to use to target the web.config file in the released folder?

There is no web.config in ASP.Net app , web.config is generated automatically after publishing the project. If you want you can add
Right click on Application folder -->Add new Item --> web.config.
To check your web.config file after Publishing the application.
Go to Azure portal , Open your Web App -->Development Tools -- >Console
Run ls command to check the existing files.
Run cat.web.config command, web.config file code will be displayed.
To Edit the web.config, download WinSCP_Setup.exe file from google and Install.
Enter the Hostname , username and password from the azure portal.
Go to Deployment Center -- > FTP Credentials
Copy the Required Hostname (FTPS endpoint), username and Password and paste in WinSCP Setup.
In right side pane of WinSCP you will find the files of your deployed application.
You can open it and edit accordingly.

You can add a web.config file at the base folder of your dotnet core app or api and then on publishing the application it will be updated in Azure App service or any IIS server where you publish.
<?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=".\MyApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
If a web.config file isn't present in the project, the file is created with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output.
Reference - MS Docs

Related

Azure Web App Virtual Application, The resource you are looking for has been removed, had its name changed, or is temporarily unavailable

I have an Azure Web Application with Virtual Application configured under the Path mappings section. The virtual path /SP2019resources has the Physical Path as site\wwwroot\SP2019resources.
My Azure DevOps pipeline will upload the contents (SharePoint SPPKG files) to this virtual path. And I have already verified that the contents are there, however whenever I formulate a URL as https://{AzureAppName}/SP2019resources/{PackageName}.SP2019.sppkg and open it in the browser the file is not getting downloaded and always getting an error as "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".
Here is the file view from my web app SCM.
Any idea what I am missing here?
After spending some time with this issue, I understood what I am missing. Essentially, you will need a Web.config file in your virtual application folder to handle the requests.
The content of the file can be as follows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="StaticHandler" verb="*" path="*" type="System.Web.StaticFileHandler" />
</handlers>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
After I add this file to the /SP2019resources, the files inside were getting downloaded.

.NET Core WebAPI IIS Deploying

I have created a webAPI using .Net Core and trying to publish it to IIS. But getting HTTP 500.19.
It's looking for web.config file but I don't have it.
What should I do?
Did you installed this: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x&view=aspnetcore-3.1
If Yes check your permissions on the folder. The identity under which your web application runs in IIS may has not full access to the folder in which the web.config file is found. You could change your identity under the appPool or grant access to your folder. If you deployed into the wwwroot folder the IUser should have access to the folder.
When you publish your .net core in IIS please remember to install .net core web hosting bundle because it is not supported by default. IIS handle request based on different handlers. Even when you install the extension, aspnet core module is not registered. So please remember to set
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<aspNetCore processPath=".\myapp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
If the solution doesn't fix this. Then something in your web.config is corrupting the application. Please post a screenshot the detailed error message. Then we would know how to fix this completely.

Can we deploy nodejs app and spring-boot app in same Azure-App-Service?

We are using 2 frameworks for developing backend:
NodeJS
Spring-Boot
Can we deploy both builds on the same Azure AppService instance?
Any suggestions?
Yes. It's similar with the other SO threads Installing wordpress on Azurewebsites running Django and How to Deploy Multiple Apps on Azure WebApps.
You can deploy an application in the path wwwroot and deploy the other as a virtual application in the other sub-path of D:\home which you configured the virtual directory and path at the tab Application settings of your website on Azure portal.
Here is the steps as reference.
Create a directory like other in the path site\wwwroot via Kudu console.
Upload the files of your two applications separately into the path wwwroot and ohter.
Create the web.config files separately in their own directory for the different applications, and their content as below.
Sample configuration web.config for starting up a SpringBoot jar, which comes from Deploying Springboot to Azure App Service
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\ROOT.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Sample configuration web.config for a Node.js application, please refer to the wiki page Using a custom web.config for Node apps.
Note to use the different absolute path for configuration to avoid the name conflict.

Azure App Service doesn't run Asp.Net Core app from VSTS

When publishing a asp.net core app using VSTS (VS2017 build task) the app won't start, build and release works without error.
Symptoms:
App doesn't start when you access the public url through the browser. No logs
when enabling even with verbose logging.
When using Publish from Visual Studio it works perfectly.
When downloading the wwwroot folder using Kudu-tools the web.exe
starts without a problem and runs just fine.
Solution: It turns out that publishing with Visual Studio 2017 adds a Web.Config file with handler mappings to the deployment with the following content which adds the default handler mapping for aspNetCore.
The strangest with this is that the Web.Config file isn't visible in Debug console, just if you download the wwwroot folder from Kudu tools. Something is strange here in the tooling even if it clear that the handler mapping is needed.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 50547f5d-25a5-4720-9216-92d42583b679-->

Deploy Spring Boot app from bitbucket pipeline to azure?

I have a standard spring boot application hosted on a Bitbucket repo which uses a bitbucket-pipeline.yml file to run a maven build
image: maven:3.3.3
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- mvn clean install
From the Upload a custom Java web app to Azure - https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-java-custom-upload Azure documentation it states that this file is needed for my spring boot app
Springboot
In order to get a Springboot application running you need to upload your JAR or WAR file and add the following web.config file. The web.config file goes into the wwwroot folder. In the web.config adjust the arguments to point to your JAR file, in the following example the JAR file is located in the wwwroot folder as well.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\my-web-project.jar"">
</httpPlatform>
</system.webServer>
</configuration>
I've two questions. Where should I add this file to the existing project directory struture? And then what commands should be added to the pipeline file to do a FTP deploy?

Resources