0
votes

I have an Blazor Application which I build and want to deploy via Azure DevOps. So far that leads to a 500.30 startup error after the deployment when deployed via Azure but it works when I deploy directly out of Visual Studio via Web Deploy.

This is the yaml of my deployment task:

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Azure App Service'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'
    packageForLinux: '$(System.DefaultWorkingDirectory)/**/*Server.zip'
    JSONFiles: '**/appsettings.json'

I do have another asp.net core WebApp (just one with razor pages) in the same solution which was built and published with the same pipeline before. When I publish that zip via the same pipeline it works as expected.

I checked via FTP to see what is the difference and noticed that I can't see the files from the deployment via Azure. But when published via Visual Studio they are in the wwwroot. Do I have to configure something specially for Blazor?

EDIT: I did find out, that the issue is in my startup.cs. The reason I don't see the files has probably to do with the permission system of the folder. I also did find out that I can get a dump with the logfiles and the eventlog where more information are via Kudu: enter image description here

1
What is the 500 error?Daniel Mann
Thanks for you response. That was kinda the issue, since I couldn't see the files, there fore no log files as well. However I found the Diagnostic Dump via Kudu and the event log in it and it is an issue with my startup.cs. Sorry if I wrote the issue incorrectly.NPadrutt
Did you see any Activity ID from the azure devops pipeline log?Merlin Liang - MSFT
@MerlinLiang-MSFT No, I can't find anything on that. But I can definitly confirm that the deployment pipeline works and that the issue was in my startup (It couldn't find a pfx file and I had to add Key Store Flags). What I'm still a bit confused about is that it worked before when I deployed from Visual Studio and that I can't see the deployed files via FTP.NPadrutt
For blazor project, it has a special deploy method, please try with Azure File Copy task. According to your issue, you mentioned that there's no files listed in its relevant path. I assume it should caused by the task used. Due to this detailed blog: chrissainty.com/deploying-blazor-apps-using-azure-pipelinesMerlin Liang - MSFT

1 Answers

1
votes

Since my question was to broad formulated, the answer here is two fold:

How to get more information from this error

As Microsoft points out in the trouble shoot document this error is when you application could not start. Regarding a Asp.Net core application this does also include everything that happens within the programm.cs and startup.cs classes. As pointed out you can see more information in the stdout (if enabled) or the Event Log. To access these, go to Advances Tools and either go to "Debug Console -> CMD" where you can see all the files or "Tools -> Diagnostic" Dump to Download a Zip which contains (among other things) these two files. In both cases it is in the LogFiles folder.

enter image description here

Fix the Crash

Now in the logfile it states that it couldn't find a specified file. In my case that was a certificate I tried to load with this line of code:

var cert = new X509Certificate2(Path.Combine(_environment.ContentRootPath, "Example.pfx"), "MyPassword");

As I found out via another SO question, if you deploy via Azure DevOps to Azure you have to set the corresponding KeyStore Flags. With the adjustment to this code it works as expected:

    var cert = new X509Certificate2("Example.pfx", "MyPassword",
                                    X509KeyStorageFlags.MachineKeySet |
                                    X509KeyStorageFlags.PersistKeySet |
                                    X509KeyStorageFlags.Exportable);