Reputation:
Due to my limited reputation point (as I am still new to StackOverflow), I am unable to comment on other posts, so I have to create a new question. However, this does not appear to be the same problem indicated in the post .net-core-2.0 azure app service 502.5 error. I am not getting the 502.5 error but rather this message:
I did perform the steps in the other post anyway to no success. I am still getting the same problem shown above. I even completely deleted my Asp.Net Core 1.1 app service and related SQL database and then re-created a new one to host my Asp.Net Core 2.0 app service. Still, no success.
Does anybody have any fresh ideas about how to fix this problem?
Thank you for your feedback.
UPDATE:
I got the following error:
SqlException: Login failed for user 'null'. System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, object providerInfo, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, bool applyTransientFaultHandling)
Upvotes: 0
Views: 721
Reputation: 5028
I just did a migration for our Azure web app from ASP.Net Core 1 to 2.0. It also uses Azure SQL. Interestingly it didn't throw any SQL related errors as you experienced. Here are some note hopefully helpful to you:
use 'Tools|Nuget package manager' to update all components to the latest 2.0 version, including ASP.Net Core and EF Core.
fix errors shown after the updates. Some are easy to fix simply following the visual studio suggestions. Some might be tricky, and needs a lot of googling and researching. the key places needs to be careful are shown below:
in Program.cs:
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddConsole();
logging.AddDebug();
})
.UseSetting("detailErrors", "true")
.UseStartup<Startup>()
.UseSetting("DesignTime", "true")
.CaptureStartupErrors(true)
.Build();
}
startup constructor becomes:
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
in ConfigureServices methods,
// authentication cookie
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/"; //new Microsoft.AspNetCore.Http.PathString("/");
options.AccessDeniedPath = "/"; //new Microsoft.AspNetCore.Http.PathString("/");
});
// Add EntityFramework's Identity support.
services.AddEntityFrameworkSqlServer();
// Add ApplicationDbContext.
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])
);
In Configure method, I added this for server side debugging:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
on Azure web portal, add a new setting key/value pair, Hosting:Environment Development:
Note: this is for debugging purpose (server-side mainly), and can be removed from production version.
Here are my lessons learned while upgrading to ASP.Net Core 2.0. If you start from your original project again, the SQL bug might not be there by following one or two points mentioned above.
Upvotes: 1