Try our conversational search powered by Generative AI!

Cuong Nguyen Dinh
May 6, 2023
  1757
(2 votes)

Troubleshoot ":( Application Error" after the very first deployment CMS 12/Commerce 14 (NET 6) in DXP

There are differences between running a CMS 12/Commerce 14 site locally and in DXP. Your site can be run locally and you have followed https://docs.developers.optimizely.com/digital-experience-platform/docs/creating-a-new-cms-site-and-deploying to deploy the very first package to your DXP integration environment but the site cannot be started.

The site home page returns

":( Application Error

If you are the application administrator, you can access the diagnostic resources."

and the log stream from DXP returns

2023-03-29T17:01:35.805270361Z info: EPiServer.Framework.Initialization.InitializationEngine[0]

2023-03-29T17:01:35.805331662Z       Initialization started

2023-03-29T17:01:51.109499486Z fail: EPiServer.Framework.Initialization.InitializationEngine[0]

2023-03-29T17:01:51.116283188Z       Initialize action failed for 'Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.12.1.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'

2023-03-29T17:01:51.116757895Z       Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 35 - An internal exception was caught)

2023-03-29T17:01:51.117438105Z        ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known

2023-03-29T17:01:51.117457305Z          at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, ValueStopwatch stopwatch)

2023-03-29T17:01:51.117463405Z          at System.Net.Dns.GetHostAddresses(String hostNameOrAddress, AddressFamily family)

2023-03-29T17:01:51.118171016Z          at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)

2023-03-29T17:01:51.118188116Z          at Microsoft.Data.SqlClient.SNI.SNICommon.GetDnsIpAddresses(String serverName)

2023-03-29T17:01:51.118563822Z          at Microsoft.Data.SqlClient.SNI.SNITCPHandle.Connect(String serverName, Int32 port, TimeSpan timeout, Boolean isInfiniteTimeout, SqlConnectionIPAddressPreference ipPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo)

2023-03-29T17:01:51.119198131Z          at Microsoft.Data.SqlClient.SNI.SNITCPHandle..ctor(String serverName, Int32 port, Int64 timerExpire, Boolean parallel, SqlConnectionIPAddressPreference ipPreference, String cachedFQDN, SQLDNSInfo& pendingDNSInfo, Boolean tlsFirst, String hostNameInCertificate)

2023-03-29T17:01:51.119217632Z          at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

2023-03-29T17:01:51.119224132Z          at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

2023-03-29T17:01:51.119229632Z          at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnectionString connectionOptions, Boolean withFailover)

2023-03-29T17:01:51.119235032Z          at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)

2023-03-29T17:01:51.119239832Z          at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)

2023-03-29T17:01:51.119262132Z          at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)

2023-03-29T17:01:51.119267432Z          at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)

2023-03-29T17:01:51.119273733Z          at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

2023-03-29T17:01:51.119278733Z          at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

2023-03-29T17:01:51.119283933Z          at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

2023-03-29T17:01:51.119288933Z          at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

2023-03-29T17:01:51.119293233Z          at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)

2023-03-29T17:01:51.119298033Z          at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)

2023-03-29T17:01:51.119302433Z          at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)

2023-03-29T17:01:51.119307533Z          at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

2023-03-29T17:01:51.119312533Z          at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

2023-03-29T17:01:51.119317633Z          at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)

2023-03-29T17:01:51.119322033Z          at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)

2023-03-29T17:01:51.119326333Z          at Microsoft.Data.SqlClient.SqlConnection.Open()

2023-03-29T17:01:51.119336934Z          at EPiServer.Data.Providers.Internal.ConnectionContext.b__15_0()

2023-03-29T17:01:51.119341734Z          at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)

2023-03-29T17:01:51.119346034Z          at EPiServer.Data.Providers.Internal.ConnectionContext.OpenConnection()

2023-03-29T17:01:51.119350734Z          at EPiServer.Data.Internal.DefaultConnectionContextHandler.CreateConnectionScope(Boolean requireTransaction, Action completeAction)

2023-03-29T17:01:51.119355534Z          at EPiServer.Data.Internal.ConnectionScopeResolver.GetConnectionScope(Boolean requireTransaction)

2023-03-29T17:01:51.119359934Z          at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.GetConnection(Boolean requireTransaction)

2023-03-29T17:01:51.119364734Z          at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass24_0`1.b__0()

2023-03-29T17:01:51.119370034Z          at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)

2023-03-29T17:01:51.119374334Z          at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.Execute[TResult](Func`1 action)

2023-03-29T17:01:51.119378634Z          at EPiServer.Data.SchemaUpdates.Internal.DatabaseVersionRetriever.GetDatabaseVersion(Boolean forceRefresh)

2023-03-29T17:01:51.119382834Z          at EPiServer.Data.SchemaUpdates.Internal.DatabaseVersionValidator.GetStatus(IEnumerable`1 connectionStringOptions)

2023-03-29T17:01:51.119387334Z          at EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation.<>c__DisplayClass6_0.b__0(ISchemaUpdater u)

2023-03-29T17:01:51.119392534Z          at System.Linq.Enumerable.SelectIPartitionIterator`2.ToList()

2023-03-29T17:01:51.119396834Z          at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

2023-03-29T17:01:51.119742240Z          at EPiServer.Data.SchemaUpdates.Internal.DatabaseSchemaManagerImplementation.EnsureDatabaseSchema(DataAccessOptions dataAccessOptions)

2023-03-29T17:01:51.119764740Z          at EPiServer.Data.DataInitialization.ValidateDatabaseSchema(InitializationEngine context)

2023-03-29T17:01:51.119770940Z          at EPiServer.Data.DataInitialization.Initialize(InitializationEngine context)

2023-03-29T17:01:51.120378249Z          at EPiServer.Framework.Initialization.Internal.ModuleNode.<>c__DisplayClass4_0.b__0()

2023-03-29T17:01:51.120418850Z          at EPiServer.Framework.Initialization.Internal.ModuleNode.Execute(Action a, String key)

2023-03-29T17:01:51.120424950Z          at EPiServer.Framework.Initialization.Internal.ModuleNode.Initialize(InitializationEngine context)

2023-03-29T17:01:51.120429850Z          at EPiServer.Framework.Initialization.InitializationEngine.InitializeModules()

2023-03-29T17:01:51.120434550Z       ClientConnectionId:00000000-0000-0000-0000-000000000000

Is there anything wrong with the DXP infrastructure? Is the database missing?

You don't have admin access to DXP. How to check it?

wondering blank Meme Generator - Imgflip

Usually, infrastructure is fine as it is quite simple and is provisioned by an automation service. There might be things wrong in the application code that make it cannot connect to DXP resources.

How DXP environments are different from local environments?

Locally you have CMS and Commerce database and point application code to them via configuration in the appsettings.json file or configuring them programmatically.

In DXP, due to security concerns, Optimizely did not expose the connection string to your databases for configuring directly.

The EPiServer.CloudPlatform.The Cms package needs to be installed and 
call

public void ConfigureServices(
    IServiceCollection services,
    IConfiguration configuration,
    IWebHostEnvironment env)
{
    ...
    if (!env.IsDevelopment())
    {
        services.AddCmsCloudPlatformSupport(configuration);
    }
}

in ConfigureServices method in the Startup.cs file to inject DXP (Azure App Service) configurations to the configuration variable for later usage.

However, the program.cs file and startup.cs files might have heavy customization and exceptions like "EPiServer.Data.DataInitialization failed", and "Microsoft.Data.SqlClient.SqlException" will be thrown when the app service cannot find the needed Azure SQL database/ Azure blob after AddCmsCloudPlatformSupport is called in DXP environments.

How DXP environments can be mimicked locally to troubleshoot the initial issue.

There is a trick that can debug the AddCmsCloudPlatformSupport locally without trial-and-error deployment attempts to DXP.

Create a launch profile for the integration environment (similar to the DXP Integration environment).

{
  "profiles": {
    "FakeDXP": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "FakeDXP",
        "CONNECTIONSTRINGS__EPISERVERAZUREBLOBS": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;",
        "CONNECTIONSTRINGS__EPISERVERDB": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=C:\\Works\\optimizely-playground\\Alloy\\App_Data\\Alloy.mdf;Initial Catalog=Alloy;Integrated Security=True;Connect Timeout=30;",
        "APPINSIGHTS_OBSERVABILITY_ENABLED": "false",
        "APPINSIGHTS_CLIENTRESOURCE_ENABLED": "false",
        "APPINSIGHTS_INSTRUMENTATIONKEY": "from DXP app configures"
      },
      "applicationUrl": "https://localhost:5000/"
    }
  }
}

In the configuration, the Azure blob connection string is emulated by Azurite.

Configure the event provider to NullEventProvider in the appsettings.FakeDXP.json file as there is no way to emulate Azure Service Bus locally.

{
  "EPiServer": {
    "Cms": {
      "EventProvider": {
        "Provider": "EPiServer.Events.Providers.Internal.NullEventProvider, EPiServer.Events"
      }
    }
  }
}

After the AddCmsCloudPlatformSupport function is called, connection strings from the environment variables can be debugged and verified if they have been injected properly.

May 06, 2023

Comments

Quan Mai
Quan Mai May 6, 2023 11:54 PM

Good stuff, keep sharing Cuong!

Ethan Schofer
Ethan Schofer May 8, 2023 02:34 PM

I am currently in the process of using this technique to troubleshoot. One not that I found, for some reason running things this way from insude Visual Studio wqas not that helpful, but from a command line using dotnet run I was able to get some usful errors.

Please login to comment.
Latest blogs
Join the Content Recommendations Work Smarter webinar May 8th 16.00-16.45 CET with expert Aidan Swain

Learn more about Content Recommendations, with Optimizely’s very own Senior Solutions consultant, Aidan Swain . He will discuss best practices and...

Karen McDougall | Apr 12, 2024

Plugin for Identifying and Bulk Deleting Orphaned Missing Properties in Optimizely

I am aware that the Optimizely World community has extensively discussed this topic, with numerous solutions and code snippets available to help...

Adnan Zameer | Apr 11, 2024 | Syndicated blog

Enhancing the Authoring Experience: Extending the LinkItem

The LinkItem field is one of the most demanded properties by the community, allowing editors to effortlessly create and manage links across pages a...

Santiago Morla | Apr 10, 2024 | Syndicated blog

The distinctions between Optimizely Web Experimentation and Optimizely Feature Experimentation

This blog is part of the series - Unlocking the Power of Experimentation: A Marketer's Insight. Let’s dive into Optimizely's powerful experimentati...

Holly Quilter | Apr 9, 2024