How to troubleshoot "Internal Server Error" in Azure MVC6 Beta8 app? - azure

I have an MVC6 Beta8 app that works locally. However when I publish it to Azure and open a home page, it return Error 500 "The page cannot be displayed because an internal server error has occurred.".
I enable the logs, but can only see kudu logs and http raw logs
2015-10-16 07:38:48 RENT-A-BIKE GET / X-ARR-LOG-ID=3c27af78-3874-4482-ac68-db29581070c1 80 - 112.207.250.32 Mozilla/5.0+(Windows+NT+10.0;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/46.0.2490.71+Safari/537.36 .AspNet.Microsoft.AspNet.Identity.Application=CfDJ8HSojZD46JRKpzcRvF66TcKzVHMrCLJRTTbz0MjK8rYaNUpfZzWwtz9EclfXXiMRUJ86IxNB_tWT5UhG03TptxP2tAXaedN0W1bQsMPhoeZR_OUrN5T0JeKZ8YAyqQkSfMmJo2rSphQFPfor7ztnbhs7vXaL0tYmsdflHAaRJH0nWs05vWuDfBkVnf7VofdoK5pICbz_QZ-HyNiH1dBzbl7CKvnzrpU7Erz4_hM4FPpAgY3hVRSuLuSYq8s9xnFNeLXI52u0DUU7GTwNYXZ946_wvjnIx706R6m4rh1c4__fLDNR6x2kPPHwWzKyftbhI3ETToJjAVtmNglY0WG9hCfZvZ_V_iCPWNmowfeU3YZ2Ux1lcDaHzr9o1o0T5ounqTzMqs_HzflN08-o7-xYF7BaqTOSjuScIWdpYDpXdzi7GAP3Hm7JPC3BG4A2GCoMjJpPDMDz6Aof9P0Td0EFB6XafDtduMewIZxf8-bGykUqoCgCb2i0dO21PFU-qkcg9kJ0LCm0kGdLERsEFLy4_a2X5vEBiyWIAlYu1JCb95l0FW87TcsMe1HwvsvubS4OkyIcKEo4UyX61AGPoRbf8OjXVvzYedG53mYdFVwsp2UARwmkGOqalp2ljGXYNCFtFkHc84ggj6XAvnnnvDCJDRAzABsNxm-b8mXtFEhgBKdzpS8Yn0egmHQNhDGP-hJy2hF-QJl8LnxjEpXg4yFtUaod54Y1_mopW11rkoWdz6aM4prIOf09TrG4NL4Y_1Ohgw;+_ga=GA1.3.68280290.1444933317;+ARRAffinity=e3c351936b5fcfb74e537a7dc58aebd6a3183747ae4ea853fe04b8e76e10ac5d - rent-a-bike.azurewebsites.net 500 19 183 466 1727 251
2015-10-16 07:38:48 RENT-A-BIKE GET /favicon.ico X-ARR-LOG-ID=5aaf9cc0-3594-4751-8571-197cc8465cef 80 - 112.207.250.32 Mozilla/5.0+(Windows+NT+10.0;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/46.0.2490.71+Safari/537.36 .AspNet.Microsoft.AspNet.Identity.Application=CfDJ8HSojZD46JRKpzcRvF66TcKzVHMrCLJRTTbz0MjK8rYaNUpfZzWwtz9EclfXXiMRUJ86IxNB_tWT5UhG03TptxP2tAXaedN0W1bQsMPhoeZR_OUrN5T0JeKZ8YAyqQkSfMmJo2rSphQFPfor7ztnbhs7vXaL0tYmsdflHAaRJH0nWs05vWuDfBkVnf7VofdoK5pICbz_QZ-HyNiH1dBzbl7CKvnzrpU7Erz4_hM4FPpAgY3hVRSuLuSYq8s9xnFNeLXI52u0DUU7GTwNYXZ946_wvjnIx706R6m4rh1c4__fLDNR6x2kPPHwWzKyftbhI3ETToJjAVtmNglY0WG9hCfZvZ_V_iCPWNmowfeU3YZ2Ux1lcDaHzr9o1o0T5ounqTzMqs_HzflN08-o7-xYF7BaqTOSjuScIWdpYDpXdzi7GAP3Hm7JPC3BG4A2GCoMjJpPDMDz6Aof9P0Td0EFB6XafDtduMewIZxf8-bGykUqoCgCb2i0dO21PFU-qkcg9kJ0LCm0kGdLERsEFLy4_a2X5vEBiyWIAlYu1JCb95l0FW87TcsMe1HwvsvubS4OkyIcKEo4UyX61AGPoRbf8OjXVvzYedG53mYdFVwsp2UARwmkGOqalp2ljGXYNCFtFkHc84ggj6XAvnnnvDCJDRAzABsNxm-b8mXtFEhgBKdzpS8Yn0egmHQNhDGP-hJy2hF-QJl8LnxjEpXg4yFtUaod54Y1_mopW11rkoWdz6aM4prIOf09TrG4NL4Y_1Ohgw;+_ga=GA1.3.68280290.1444933317;+ARRAffinity=e3c351936b5fcfb74e537a7dc58aebd6a3183747ae4ea853fe04b8e76e10ac5d http://rent-a-bike.azurewebsites.net/ rent-a-bike.azurewebsites.net 500 19 183 466 1696 31
I also tried to disable custom errors in web.config, but it doesn't work (and as I understand starting from Beta8 is not supposed to work).
How can I troubleshoot this problem to see an actual error that occurred?

After I enabled "Detailed Error Messages" is Azure web app configuration, I was able to see DetailedErrors folder in Log Files directory that had a number of .html files with error details.

For that detailed errors begins appear in DetailedErrors folder in Log Files directory - restart your application in Azure.

In project.json file, for the web command specify the environment parameter = development
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --ASPNET_ENV development",
}
In the Startup.cs file, in Configure you should have:
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
This means that when you run in other hosting environment that development, the Error page will be displayed instead the DeveloperExceptionPage.

Related

Attempt to publish the ZIP file through https://xxx.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code Forbidden

I'm getting this error window message while trying to deploy a .NET 6 Azure Functions app to Azure from Visual Studio 2022:
Publish has encountered an error. We
were unable to determine the cause of the error. Check the output log
for more details.
A diagnostic log has been written to the following location:
"C:\Users\MyUserName\AppData\Local\Temp\tmpEB87.tmp"
The tmpEB87.tmp file contents look like this:
2/16/2022 1:43:18 PM
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
===================
The Output log says this:
The attempt to publish the ZIP file through
https://xxx.scm.azurewebsites.net/api/zipdeploy failed with HTTP
status code Forbidden.
The MyFunctionName - Zip Deploy.pubxml file contents looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>ZipDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>https://xxx.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ResourceId>/subscriptions/some-random-letters-123456789/resourceGroups/my-resource-group-name/providers/Microsoft.Web/sites/MyFunctionName</ResourceId>
<UserName>$MyFunctionName</UserName>
<_SavePWD>True</_SavePWD>
<IsLinux>true</IsLinux>
<PublishUrl>https://xxx.scm.azurewebsites.net/</PublishUrl>
</PropertyGroup>
</Project>
I've already spent a ton of time on this, so any help is appreciated.
One of the workarounds that you can try is to create a new Publish profile and publish it again. For this navigate to Your project's directory -> Properties -> Publish Profiles and delete the contents (or you can move to another location). Finally, click Finish in the publish profile wizard again.
Make sure WEBSITE_RUN_FROM_PACKAGE is 1 from your Application settings. Also, try restarting your function app.
NOTE:- When deploying from Visual Studio, you should be asked whether you want to upgrade the version of the app that is currently deployed. If you say yes, your app will be deployed.

Yii2 Framework to Azure Web App (404 Page Not Found)

Thank for reading my post.
I'm having an issue making my Website Application(Yii2) works correctly in Azure Web Apps. I've migrated my Yii2 Websites from an existing server to the Azure Web Apps. After lots of manipulation listed below, I’m able to access the Website.
The main theme loads successfully but throwing "404 Page not found
The requested page is missing, or the address has been changed" Error in the body and others links in the "Menu Bar" not working too. "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
The Azure Resources are configured as below:
1 x App Service Plan : S1:1 (Windows Base)
1 x Azure Database for MySQL server
1 x App Service (The Web App)
App Service Application Setting:
.Net Framwork: v4.7
PHP Version: 7.0
Platform: 32bit
Migration Steps:
FTP all files/folder from htdocs in my existing server to my App Service Plan (\site/wwwroot)
Generate the SQL Table creation in PhpAdmin
Find and Replace ENGINE=InnoDB DEFAULT CHARSET=utf8; in the script
Connect to Azure Database for MySQL server, create new Schema and Run the Script
From Azure, KUDU Inferface browse (\site\wwwroot\config) and change the db.php to
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=xxxx.mysql.database.azure.com;dbname=xxxxx',
'username' => 'xxxxxxx#xxxxxxxxxxxxxxxxxx',
'password' => 'xxxxxx',
'charset' => 'utf8',
];
Restart the Web App
Check the https://yourdomain.com/requirements.php (Passed without any Error)
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable" when trying to browse the new Web App.
KUDO PowerShell windows browse back to site/wwwroot and executed the following line of codes
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php composer.phar global require "fxp/composer-asset-plugin:^1.2.0"
Browse to the Directory (\site\wwwroot\web) and change index.php with the following line of codes:
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
}
}
// comment out the following two lines when deployed to production
('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../config/web.php');
(new yii\web\Application($config))->run();
From the Azure Portal / Web App / Application settinh, .change the default directory from site\wwwroot to site\wwwroot\web
Restart the Web App.
The home page them now loads successfully but with a 404 Error within the body and "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." when trying to access other pages in the header.
I also noted that I have 2 .htacss file
1x in my \site\wwwroot and 1x in my \site\wwwroot\web
Haved tried deleting them and configure a web.config file in (site\wwwroot\web) but still not working.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="https://mysitename.azurewebsites.net/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
As Yii2 is not famous in Azure Web App, can't find a solution anywhere. Will appreciate if you can help along.

An assembly specified in the application dependencies manifest was not found

So I have a .NET Core 2.2 web application.
I added the EPPlus library to it and now, when it is released to Azure (App Service) it won't start and I get the error:
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure
I narrowed this down by running a console in Azure and the command: "dotnet my.project.dll" - and got the actual error:
An assembly specified in the application dependencies manifest
(my.project.deps.json) was not found:
package: 'Microsoft.Win32.SystemEvents', version: '4.5.0'
path: 'runtimes/win/lib/netcoreapp2.0/Microsoft.Win32.SystemEvents.dll'
The Microsoft.Win32.SystemEvents.dll is present in the main wwwroot folder the application is deployed to.
But the whole runtimes/win/libs/ folder I don't think exists at all.
The my.project.deps.json files has the section which looks like this:
"Microsoft.Win32.SystemEvents/4.5.0": {
"dependencies": {
"Microsoft.NETCore.Platforms": "2.2.0"
},
"runtime": {
"lib/netstandard2.0/Microsoft.Win32.SystemEvents.dll": {
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp2.0/Microsoft.Win32.SystemEvents.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.0.0.0",
"fileVersion": "4.6.26515.6"
}
}
}
If I delete the whole "runtimeTargets" section, then the application works! (Well, I have to do the same for a few more dll's too: System.Drawing.Common and System.Security.Cryptography.Pkcs)
But the file gets regenerated fully whenever it is published and released - so it is not a viable solution.
I also don't know what that section of the file does. It might be important to leave it in. Though it all works so it can't be that vital...
It is built and published through TeamCity - I'm not an expert on the process but I think the command being run amounts to this:
dotnet publish my.proj.csproj --configuration RELEASE --no-restore --no-build
Other things tried: < PublishWithAspNetCoreTargetManifest>false< / PublishWithAspNetCoreTargetManifest>
had no effect
Anyone have any ideas?
As it turns out, it was my fault :(
Team City was created a NuGet package from the published output. But the /runtimes folder was not included in the package so was never released as part of the site.
I edited the nuspec file to include it /runtimes and all works OK.
I've had same issue. After the build I copied all files to the "production" directory by DOS command copy so then the files from "runtimes" subfolder were missing. Copying all files including all subdirectories (by using xcopy) fixed the issue.

ASP.NET Core fails to run under IIS: HTTP Error 500.0 - ANCM In-Process Handler Load Failure

I just upgraded my web application from ASP.NET (Framework) MVC to ASP.NET Core 2.2. The application runs fine under IIS Express, however as soon as I try to run it under IIS it gives the generic error:
HTTP Error 500.0 - ANCM In-Process Handler Load Failure Common causes
of this issue: The specified version of Microsoft.NetCore.App or
Microsoft.AspNetCore.App was not found. The in process request
handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the
application. ANCM could not find dotnet.
I've searched the web and see that many developers are running into the same issue, it seems that Microsoft really missed the mark on this one and have made it as painful as possible to develop ASP.NET Core apps under IIS. Regardless, I'd like to break through this brick wall that I've been hitting my head against for the last 24 hours, so could use some help.
Things I've tried so far:
Installed the latest version of .NET Core Runtime and Hosting Bundle, version 2.2.4.
Installed the latest version of .NET Core SDK, version 2.2.203.
Ensured that "dotnet" is runnable from command line, and that the x64 version is before the x86 version in my environment variables.
C:\WINDOWS\system32>where dotnet C:\Program Files\dotnet\dotnet.exe
C:\Program Files (x86)\dotnet\dotnet.exe
Tried changing my auto-generated Web.config from aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" to aspNetCore processPath="dotnet" arguments="./Housters.Web.dll" however the changes don't stick, every time I build my web application the Web.config gets reverted back tot he original %LAUNCHER_PATH% values.
Tried changing "AspNetCoreModuleV2" to "AspNetCoreModule" in the Web.config.
Added IsTransformWebConfigDisabled=true to my Web.csproj file in order to keep my custom Web.config from being overwritten. It didn't work, the Web.config is still overwritten.
Tried switching AspNetCoreHostingModel=InProcess to RuntimeFrameworkName=Microsoft.AspNetCore.App in my Web.csproj file.
Cleaning the solution, as well as manually deleting the bin, obj, and even .vs folders.
None of these methods helped, I still get the same ANCM In-Process Handler Load Failure error. The Event Viewer does show a more useful error:
Application 'C:\Housters\Web\' wasn't able to start. Executable was
not found at 'C:\Housters\Web\%LAUNCHER_PATH%.exe'
However, I can't do anything about that because my Web.config changes don't persist. But really, the default settings should work out of the box, we shouldn't have to jump through hoops to get IIS development working. Why is it looking for an .exe when an ASP.NET Core project by default only generates a .dll? And why isn't it replacing %LAUNCHER_PATH% with the correct path, e.g. "bin/Debug"?
EDIT: I should also mention that at times I've been able to get my custom Web.config to persist, and when I do then every time I try to run the web application I get a JIT debugger prompt:
Choosing to debug, or viewing the event log just gives me a really unfriendly error message:
Faulting application name: w3wp.exe, version: 10.0.17134.1, time
stamp: 0xed729d4e Faulting module name: KERNELBASE.dll, version:
10.0.17134.556, time stamp: 0xb9f4a0f1 Exception code: 0xc0020001 Fault offset: 0x000000000003a388 Faulting process id: 0x2650 Faulting
application start time: 0x01d502b1f21b112e Faulting application path:
c:\windows\system32\inetsrv\w3wp.exe Faulting module path:
C:\WINDOWS\System32\KERNELBASE.dll Report Id:
5b5c14cb-8ffa-47b4-8cc1-42f951bc1256 Faulting package full name:
Faulting package-relative application ID:
You're getting this error because you're not specifying if you want the website hosted in process or out of process... in process can be specified by using UseIIS().
Try changing your CreateWebHostBuilder method in Program.cs to:
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var builder = WebHost.CreateDefaultBuilder(args);
if (env == EnvironmentName.Staging || env == EnvironmentName.Production)
builder.UseIIS();
builder.UseStartup<Startup>();
return builder;
}
I set ASPNETCORE_ENVIRONMENT in my .pubxml deployment profile by adding:
<PropertyGroup>
<EnvironmentName>Staging</EnvironmentName>
</PropertyGroup>
The cause of this error may also be because the version of the .NET SDK which is in the global.json file of your application is not installed on your local machine. The solution is to check which version is configured in the global.json file and install it on your machine. I managed to solve this error this way (01/06/2022).
The following error will appear in the Windows Event View:
I solve this error just by changing in the web.config AspNetCoreModuleV2 to AspNetCoreModule, but this is not perfect solution.
Another solution is deploying application as Self-Contained when you will publish it.

Veracode through an error - ASPCONFIG: Could not autodiscover 'components.config'

I have a Veracode plugin in my VS 2013 Professional.
I have ucommerce.dll, Sitecore.Kernel and Sitecore.Analytics.dll
I set copy local true for all above dll files.
When i tried to pre-compile all the web project I'm getting a below error message
1>------ Pre-compile started: Project: XXXXX.Web.PQRPorta\ ------
1>Pre-compiling with command similar to the following:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -p
"C:/XXXXX.Web.PQRPortal" -v "XXXXX.Web.PQRPortal/" -fixednames -f -c
-d "C:/SVN/trunk/Releases/SourceCode/Source/PrecompiledWeb/XXXXX.Web.PQRPortal"
1>error ASPCONFIG: Could not autodiscover 'components.config'. Make
sure it's present in the application folder
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\' or in a
sub folder. Paths ignored
''C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\bin',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\App_Data',
'C:\SVN\trunk\Releases\SourceCode\Source\XXXXX.Web.PQRPortal\obj''
1>XXXXX.Web.PQRPortal\ - 1 error, 0 warnings
Is there any configuration missing?
Update
I found the components.config file inside
C:\inetpub\wwwroot\XXXX\Website\sitecore modules\Shell\uCommerce\Configuration
and I added the file inside the web project root directory and tried to precompile web project, now I’m getting different error error
ASPRUNTIME: Type is not resolved for member 'Castle.Windsor.Configuration.Interpreters.ConfigurationProcessingException,Cast‌​le.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
any solution for it?
The components.config is a file uCommerce need.
The configuration file should be placed somewhere below the uCommerce folder. (not sure where depend on the version) It will automatically be picked up when the application starts up.

Resources