Base solution for your next web application
Open Closed

Deployment to Azure App Service #9873


User avatar
0
alfar_re created
  • Version 9.1
  • MVC
  • .NET Core

I'm having issues publishing an app built on the above to Azure app service with all settings correct. Below is the error am getting via the Kudu Diagnostics Console since that is the only way am able to get to the app after hosting.

Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value') at System.Boolean.Parse(String value) at lipasasa.Web.Startup.Startup.ConfigureServices(IServiceCollection services) in ...Mvc\Startup\Startup.cs:line 80 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection) at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services) at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.WebHost.Initialize() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at lipasasa.Web.Startup.Program.Main(String[] args) in ...Web.Mvc\Startup\Program.cs:line 12


8 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you share what is in your Startup.cs:line 80 ? Probalby some of the settings are missing in your appsettings.json file (or the one related to current environment).

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    Now it is on line 72 which is below.

    if (bool.Parse(_appConfiguration["KestrelServer:IsEnabled"])) { ConfigureKestrel(services); }

    Another thing I noted is that on the Azure Application Insights I get the following error;

    Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'Id', table 'lipasasav1Db.dbo.AbpAuditLogs'; column does not allow nulls. INSERT fails. The statement has been terminated.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Now it is on line 72 which is below.

    Do you have this configuration in your appsettings file ?

    Another thing I noted is that on the Azure Application Insights I get the following error;

    Could you share the full stack trace ? Id column must be auto-increment and should be set by database provider automatically. Could you check if this field set to auto-increment on the database ?

    Thanks

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas,

    I only have this in my appsettings file

    "KestrelServer": {
        "IsEnabled": true
      }
      
    

    Here is the stack trace from Azure. The id is also auto-increament. The below trace is from the Debug Console.

     Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'value')
       at System.Boolean.Parse(String value)
       at lipasasa.Web.Startup.Startup.ConfigureServices(IServiceCollection services) in ****.Web.Mvc\Startup\Startup.cs:line 72
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.&lt;&gt;c__DisplayClass9_0.&lt;Invoke&gt;g__Startup|0(IServiceCollection serviceCollection)
       at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass15_0.<BuildStartupServicesFilterPipeline>g__RunPipeline|0(IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.&lt;&gt;c__DisplayClass14_0.&lt;ConfigureServices&gt;g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
       at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
       at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
       at lipasasa.Web.Startup.Program.Main(String[] args) in ***.Web.Mvc\Startup\Program.cs:line 12
       
    

    This is from the azure app insights error 500 trace

    Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'Id', table 'lipasasav1Db.dbo.AbpAuditLogs'; column does not allow nulls. INSERT fails.
    The statement has been terminated.
       at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
       at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
       at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
       at Microsoft.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader(Boolean isInternal, Boolean forDescribeParameterEncryption)
       at Microsoft.Data.SqlClient.SqlCommand.InternalEndExecuteReader(IAsyncResult asyncResult, Boolean isInternal, String endMethod)
       at Microsoft.Data.SqlClient.SqlCommand.EndExecuteReaderInternal(IAsyncResult asyncResult)
       at Microsoft.Data.SqlClient.SqlCommand.EndExecuteReaderAsync(IAsyncResult asyncResult)
       at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
    ClientConnectionId:0b05f022-22b7-4c50-a945-7e536764864b
    Error Number:515,State:2,Class:16
    ClientConnectionId before routing:4fc32061-6cb8-431a-8869-029aca81b773
    Routing Destination:c1fd9552a407.tr18.northcentralus1-a.worker.database.windows.net,11064
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    For the first problem, are there any other appsetting files in the same directory ? If so, could you move this config to other settig files and restart your website ?

    For the second problem, is it possible for us to access your azure database ? If so, could you share the instructions via email with [email protected] ?

    Thanks,

  • User Avatar
    0
    alfar_re created

    Hi @ismcagdas

    I deleted it and created a new one and run migrations. Removed some config files at the root of the app and restarted the app. I also added the connection string to the application settings and it worked.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @alfar_re

    Glad that it worked. Probably it was related to additional or missing appsettings.json files.

  • User Avatar
    0
    alfar_re created

    Yes. I also cleaned the project, deleted all app files on the app service and re-uploaded.