Chicheng's Blog

PhD := Pathetic Human Dying, But Enjoyable.

0%

Deploy .NET core to Azue

Open the release setting window

Find the release window under the Build tab:

Pressing the start button to finish the publishing process.

After pressing this start button, a window will pop out. And, just follow the instruction to fill and the fields.

Set up the dependencies

After you complete the fields about your sever. It will point out the dependency you need. You can press Configure to set up your dependency. And you are good to go. Just press the Publish button you can publish your serve to Azure cloud.

Bugs

HTTP Error 500.30 - ANCM In-Process Start Failure

Solution

This may happen when publishing the server to Azure. This message means the server on the azure doesn’t start correctly. Therefore, any request to the server will get this message as response. To understand what’s going on on the Azure server, we have to first go to the Azure console and find the console to run the solution again here.

To run the solution again in this console, we can get the same result of the output window during debugging locally. According to the demonstrated message above, the bug is prababaly caused by the Mirgation Error. Since the data in the database is jus for the use of testing, we can directly remove all the migrations and migrate them when the app start by the following code in Program.cs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public static void Main(string[] args)
{
Console.WriteLine("Running Start");
IHost host = CreateHostBuilder(args).Build();

// Intialise the SQL Db before running the Host
using (IServiceScope scope = host.Services.CreateScope())
{
try
{
DivingAPIContext context = scope.ServiceProvider.GetService<DivingAPIContext>();

// Ensuring the Db Status
context.Database.EnsureCreated();
context.Database.Migrate();

}
catch (Exception ex)
{
ILogger<Program> logger = scope.ServiceProvider.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occured while Operating the Db");
throw;
}
}

host.Run();
}

Steps:

  • Remove the migrations and database. (If you don’t want to remove the database, you can update your database to previous version and do the same tricks below).
  • Run migration during the app start.

Another solution (Not working on my case, but may help your):

[Click here to see another solution]