Unable to debug with Azure SQL Database (reaching Install Umbraco page)

Hi all, I’m trying to set up a development environment to our Umbraco 13.12.1 site. The problem is that other developers always reach the “Install Umbraco” page despite connecting to an existing Umbraco database. When I’m running on the same branch, I progress to our index page as expected.

One difference I can come up with is that I am “Microsoft Entra admin” on the SQL Server resource in Azure. The other developers are in an Entra group that are db_owners on the database.

USE [ContosoDev]
CREATE USER [Website developers] FROM EXTERNAL PROVIDER WITH OBJECT_ID='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';

ALTER ROLE db_owner ADD MEMBER [Website developers];

I verified that they can open a connection and query the database from another SQL Client. Here’s the connection string used in appsettings.Development.json:

  "ConnectionStrings": {
    "umbracoDbDSN": "Data Source=contoso-server.database.windows.net;Initial Catalog=ContosoDev;Encrypt=True;TrustServerCertificate=False;Authentication=Active Directory Default;"
  }

For troubleshooting I added this snippet to Program.cs:

if (builder.Environment.IsDevelopment())
{
    var connectionString = builder.Configuration.GetConnectionString("umbracoDbDSN");
    Debug.WriteLine("=== DATABASE CONNECTION DIAGNOSTIC ===");
    Debug.WriteLine($"Connection string found: {!string.IsNullOrEmpty(connectionString)}");

    if (!string.IsNullOrEmpty(connectionString))
    {
        try
        {
            Debug.WriteLine($"Server: {new SqlConnectionStringBuilder(connectionString).DataSource}");
            Debug.WriteLine($"Database: {new SqlConnectionStringBuilder(connectionString).InitialCatalog}");
            Debug.WriteLine($"Authentication: {new SqlConnectionStringBuilder(connectionString).Authentication}");
            Debug.WriteLine("Attempting to connect...");

            using var connection = new SqlConnection(connectionString);
            connection.Open();
            Debug.WriteLine("✓ Database connection successful!");

            using var command = connection.CreateCommand();
            command.CommandText = "SELECT COUNT(*) FROM umbracoUser";
            var userCount = command.ExecuteScalar();
            Debug.WriteLine($"✓ Found {userCount} Umbraco users in database");
        }
        catch (Exception ex)
        {
            Debug.WriteLine($"✗ DATABASE CONNECTION FAILED!");
            Debug.WriteLine($"Error: {ex.Message}");
            Debug.WriteLine($"Type: {ex.GetType().Name}");
            if (ex.InnerException != null)
            {
                Debug.WriteLine($"Inner Error: {ex.InnerException.Message}");
            }
            Debug.WriteLine("This will cause Umbraco to show the install screen.");
        }
    }
    else
    {
        Debug.WriteLine("⚠ No connection string configured!");
    }
    Debug.WriteLine("=== END DIAGNOSTIC ===");
}

Then I verified that we get these lines in Visual Studio’s debug output (but are still reaching the “Install Umbraco” page):

=== DATABASE CONNECTION DIAGNOSTIC ===
Connection string found: True
Server: contoso-server.database.windows.net
Database: ContosoDev
Authentication: ActiveDirectoryDefault
Attempting to connect...
✓ Database connection successful!
✓ Found 11 Umbraco users in database
=== END DIAGNOSTIC ===

Hi @William

Do the other developers users use the default dbo schema and is your last output with the diagnostics from another developer or yours?

It’s also worth pointing out that sharing a dev database may not be the best idea as you will effectively be load balancing your dev environment which could cause issues with locks, background jobs and other back office issues.

Justin

1 Like

Do the other developers users use the default dbo schema

No, running this query

SELECT name, default_schema_name 
FROM sys.database_principals 
WHERE name = 'Website developers'

Resulted in a row with default_schema_name=null. After running this

ALTER USER [Website developers] WITH DEFAULT_SCHEMA = dbo;

It worked! Thank you Justin.

Did I miss something in the Umbraco docs about this or is it just something you usually don’t have to consider / it’s trivial SQL Server knowledge?

[…] is your last output with the diagnostics from another developer or yours?

To clarify this was taken from the other developer’s machine. But we both got the same output.

It’s also worth pointing out that sharing a dev database may not be the best idea as you will effectively be load balancing your dev environment which could cause issues with locks, background jobs and other back office issues.

We are a small team so I think we can take this risk for now to avoid the hassle of setting up local SQL Server instances.

No, I’m not aware it’s documented - I think it’s just accepted that you need to know to use the dbo schema as all the tables belong to that schema.

That’s why I questioned as your query for:

SELECT COUNT(*) FROM umbracoUser

Should have failed as the schema was not specified (unless it defaults to dbo but they would not have had permissions for that schema?).

At least you have it working!

Justin

Just as an FYI: this is not documented as it is “regular” SQL behavior. You don’t need to use dbo but the schema must be the same for everyone. So if you have different SQL users, they all must have the same default schema, be that dbo or blablabla.

1 Like