ASP .Net core project CI\CD fails in Publish using DevOps Project - azure

We have an ASP.Net core 2.1 Devops project build and released successfully. But when we try accessing we are getting error.
HTTP Error 502.5 - Process Failure
If we take the drop from artifacts and try local it is working perfect. Please help!

After enabling stdoutLog, we got the following error details.
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.0-preview1-final' was not found.
- Check application dependencies and target a framework version installed at:D:\Program Files (x86)\dotnet\ - Installing .NET Core prerequisites might help resolve this problem:http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:https://aka.ms/dotnet-download - The following versions are installed:2.1.2 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
Our application was using '2.1.0-preview1-final', seems Azure installed the latest version 2.1.2 for the DevOps environment. We updated our application with Core 2.1.2 and tried again. Now the application runs successfully without any error.
Thank you Martin Brandl!

Your best shot will be to enable logging to track down the error:
Go to the Kudu environment (https://YOURSITE.scm.azurewebsites.net)
On the top menu, select Debug console -> PowerShell
Navigate to site -> wwwroot and open the web.config
Set the stdoutLogEnabled attribute to true and save the file.
Create a folder named logs next to the web.config using mkdir logs
Now if you try to browse your site again, you should see a log file within the previously created directory containing additional information.
See also:
Determine whats wrong with your Azure Web / API App deployment

Related

migrated .net core 2.2 app to 3.1 and it won't serve up in Azure

I have everything working locally, I have updated my build/deploy pipeline in Azure Dev Ops and everything builds and deploys fine however, when I call the site on my app service I get this error:
I have tried to find on the app service configuration page the place to change the .net core version (found this resource: https://www.hanselman.com/blog/UpdatingAnASPNETCore22WebSiteToNETCore31LTS.aspx) but I don't see any place to change the version - just the stack type. See 2nd screenshot:
Where do I need to go to update this to version 3.1? All other searches I"ve tried are coming up empty.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
1.In the DEVELOPMENT TOOLS blade section, select the Extensions blade.
2.The ASP.NET Core Extensions should appear in the list.
3.If the extensions aren't installed, select the Add button.
4.Choose the ASP.NET Core Extensions from the list.
5.Select OK to accept the legal terms.
6.Select OK on the Add extension blade.
7.An informational pop-up message indicates when the extensions are successfully installed.
After install ASP.NET Core 3.1(x64) Runtime Extension, then you will load your webapp successfully. Refer to this article to migrate from 2.2 to 3.1.

Exception during publishing web app to Azure

We have created a sample Asp.net Core application. When we tried to publish the application into Azure we got following exception.
Web deployment task failed. (The type initializer for 'Microsoft.Web.Deployment.DeploymentManager' threw an exception.)
We have tried some solutions posted in some blogs but none got the issue resolved.
Here are some ways you could try:
1.Look for a key in the registry under the following paths that points the the problem assembly and delete it:
HKLM\Software\Microsoft\IIS Extensions\msdeploy\3\extensibility
HKLM\Software\Wow6432Node\Microsoft\IIS Extensions\msdeploy\3\extensibility
The problem registry key is installed by SQL.
2.Reinstall Web Deploy 3.5.
3.Uninstall dbsqlpackage provider . this packages no longer support.
4.Restarted Visual Studio and rebuilt the project.
For more details, you could refer to this thread.
It sounds like you are trying to create a web job and publish it to a App Service in Azure. To do this you have to create a Azure WebJob project type in visual studio. To get this project type in VS you have to install it or download it using nuget.
Installing "Web Deploy 3.5" extension helped me solve this issue.
https://www.iis.net/downloads/microsoft/web-deploy

ajaxcontroltoolkit missed when trying to republish published files on another machine or my local IIS

I have a published web application on specific server. I want to run the same application on another IIS server, but i get this error
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. Access is denied.
Exception is here
Installing Report Viewer fixed it.
The problem was that my web.config was targeting .NET 2.0 and has some configuration related to .NET 2.0. I've updated the solution projects to target .NET 4.0 which need the report viewer dll in GAC folder or something global and that's what report viewer installer will do.

Asp.Net Core 2.0 on Azure results in a 502.5

I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:
This error occurs when a CGI application does not return a valid set
of HTTP headers, or when a proxy or gateway was unable to send the
request to a parent gateway. You may need to get a network trace or
contact the proxy server administrator, if it is not a CGI problem.
Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).
For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.
Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.
EDIT
When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'Microsoft.AspNetCore.Hosting.Abstractions,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?
the issue was actually coming from the fact that, at first, my web app was using .net core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp.net core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.
This is explained in more details here: https://github.com/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550
Others have explained the reason why this is happening. I'd like to provide another – arguably easier – solution to the problem.
Just change the settings so that you remove files that are already on Azure – see below:
Check for log files either in the portal or by remotely accessing D:\home\LogFiles.
Sometimes, the logs won't indicate what is going wrong. Another good way to investigate further is to try launching your ASP.NET Core app from the Debug Console. If you are missing a shared framework version or there is another startup error, this will be more visible from the Debug Console.
Go to
https://(your web site name here).scm.azurewebsites.net/DebugConsole/
Your site will be in D:\home\site\wwwroot. You can launch it by executing:
cd D:\home\site\wwwroot
dotnet MyWebApp.dll
If you app still fails to launch, make sure that D:\home\site\wwwroot\web.config is available and configured to use ASP.NET Core Module. https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module
In my case, It was caused by having a space in the Project Name.
I can readily add a space, publish => 502.5.
Remove space, publish => good to go.
Hard to believe but I am duplicating it readily with above.
Also using "Remove Additional Files at Destination" per #Sam's Answer
See https://github.com/Azure/app-service-announcements/issues/14
"The rollout is expected to complete by Friday June 30th."
In my case the issue occurred because AppService at that time supported 2.0.0-preview2-006497 but I had 2.0.0-preview3-006890 installed which was used on build.
So I added global.json to use preview 2 SDK and it worked then
I don't know if this could help someone one day but in my case, I was using :
-Microsoft.AspNetCore.All 2.0.5
Downdrage to Microsoft.AspNetCore.All 2.0.3 resolve my problem
This happens when your version of ASP.NET Core cannot be matched on the server.
The simplest solution is to change your settings to deploy the app as self-contained, so it doesn't matter if Azure can match the framework version. Also, delete the files already on Azure, so you don't have issues when upgrading, as explained by #Sam.

Failed to debug the Windows Azure Cloud Service Project. The output directory does not exist. / Azure SDK 2.3 / VS 2013

I have Azure SDK 2.3 installed on my Windows 7 machine. The target .Net framework is set to 4.0. I'm able to upgrade my solution to Azure SDK 2.3 and build with no problems. However, when I try to run the solution, I get the following error:
Failed to debug the Windows Azure Cloud Service project. The output directory does not exist.
If I revert the solution back to Azure SDK 2.2, the problem goes away. So there's some configuration that's added by the Azure SDK 2.3 upgrade that is causing this issue. This ONLY happens when I'm running the Azure Emulator. One thing I've noticed is that the build process somehow removes the "Debug" folder from the csx directory. When I manually add it back in, the build process removes it again and then I get the same error above. I'm at a loss as to what might be causing this since my "Active solution configuration" is all set to DEBUG for "Configuration" and ANY CPU for "Platform". I've tried all the troubleshooting steps from earlier threads on this issue (with Azure SDK 1.8) with no luck. I would appreciate any helpful suggestions on this. Thanks.
NOTE: Interestingly enough, if I deny all rights to the DEBUG folder in CSX, the emulator launches but then it fails because it doesn't have access to the DEBUG folder. So I'm puzzled by why the VS build process wants to remove that Debug folder.
ANOTHER NOTE: Apparently, it's the normal process for VS Build to wipe out the Debug folder. The run process with debug is supposed to recreate that Debug folder with everything in it. That doesn't happen. I confirmed this by reverting it back to Azure SDK 2.2 and noted that the run w/ debug actually recreates that Debug folder. This recreation process fails to happen when I upgrade to 2.3.
For me, the issue was I changed the Debug Solution Configuration to something other than Debug. Renaming it back to Debug fixed the issue.
I was able to solve this issue by simply uninstalling Azure SDK 2.3 and then re-installing it. That's it!
Got it solved by doing the following:
Change to "Release" configuration.
Build and run.
Change back to "Debug" configuration.
Build and run. No error now.
I was seeing the same error that the csx folder was empty. Doing the following fixed my issue:
Right click your *.ccproj > Debug > Start New Instance
None of the above worked for me, what did work was deleting the file
{YourProject}.ccproj.user
Close and reopen VS, build and run

Resources