Squidex Within an Azure App Service: MongoDb connection failed to connect to database Squidex

I’m new to Squidex and MongoDB and I’m trying to set up Squidex within an Azure App Service following this guide:

I’ve completed the setup without issues and I’m able to connect to my MongoDb instance locally, without issue, using the user I’ve configured as an administrator within my Squidex Mongo Database.

However, my App Service fails to start with the following error:

2021-02-18T00:45:27.806844798Z Unhandled exception. Squidex.Hosting.Configuration.ConfigurationException: MongoDb connection failed to connect to database Squidex.
2021-02-18T00:45:27.806899798Z
2021-02-18T00:45:27.806905498Z  ---> MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1.
2021-02-18T00:45:27.806910099Z  ---> MongoDB.Driver.MongoCommandException: Command saslStart failed: Authentication failed..
2021-02-18T00:45:27.806914099Z    at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ProcessReply(ConnectionId connectionId, ReplyMessage`1 reply)
2021-02-18T00:45:27.806918499Z    at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)
2021-02-18T00:45:27.806931099Z    at MongoDB.Driver.Core.Authentication.SaslAuthenticator.AuthenticateAsync(IConnection connection, ConnectionDescription description, CancellationToken cancellationToken)
2021-02-18T00:45:27.806935599Z    --- End of inner exception stack trace ---
2021-02-18T00:45:27.806948099Z    at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
2021-02-18T00:45:27.806952999Z    at MongoDB.Driver.Core.Servers.Server.GetChannelAsync(CancellationToken cancellationToken)
2021-02-18T00:45:27.806956899Z    at MongoDB.Driver.Core.Operations.CreateIndexesOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
2021-02-18T00:45:27.806960799Z    at MongoDB.Driver.OperationExecutor.ExecuteWriteOperationAsync[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)
2021-02-18T00:45:27.806964699Z    at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperationAsync[TResult](IClientSessionHandle session, IWriteOperation`1 operation, CancellationToken cancellationToken)
2021-02-18T00:45:27.806970799Z    at MongoDB.Driver.MongoCollectionImpl`1.MongoIndexManager.CreateManyAsync(IClientSessionHandle session, IEnumerable`1 models, CreateManyIndexesOptions options, CancellationToken cancellationToken)
2021-02-18T00:45:27.806974799Z    at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
2021-02-18T00:45:27.806978699Z    at Squidex.Infrastructure.MongoDb.MongoRepositoryBase`1.InitializeAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs:line 113
2021-02-18T00:45:27.806984099Z    --- End of inner exception stack trace ---
2021-02-18T00:45:27.806987899Z    at Squidex.Infrastructure.MongoDb.MongoRepositoryBase`1.InitializeAsync(CancellationToken ct) in /src/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs:line 119
2021-02-18T00:45:27.806991899Z    at Squidex.Hosting.InitializerHost.StartAsync(CancellationToken cancellationToken)
2021-02-18T00:45:27.806995599Z    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2021-02-18T00:45:27.806999399Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2021-02-18T00:45:27.807003099Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2021-02-18T00:45:27.807006899Z    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2021-02-18T00:45:27.807930204Z    at Squidex.Program.Main(String[] args) in /src/src/Squidex/Program.cs:line 22

I’m using a connection string similar to this within the EVENTSTORE__MONGODB__CONFIGURATION and STORE__MONGODB__CONFIGURATION application settings in my App Service:

mongodb://[USER_NAME]:[PASSWORD]@[MONGO_IP]:27017

Sorry, I don’t know all the details of MongoDB. When I google it i find solutions like using the following connection string:

mongodb://myUser:myPassword@servername:27017?authSource=database_nam

1 Like

I appreciate your quick response, that did the trick!