Skip to content

Login failed for user '<token-identified principal>' after PublishAsAzureSqlDatabase #4475

@4eversoft

Description

@4eversoft

After deployment via 'azd up' the connection from my container apps to the Azure SQL database failed.

The SQL Server and the database are defined as follows in AppHost:

var travelLoungeMsSql = 
    builder
        .ExecutionContext.IsPublishMode ?
    builder
        .AddSqlServer("travellounge-mssql")
        .PublishAsAzureSqlDatabase() :
    builder
        .AddSqlServer("travellounge-mssql", password: msSqlPassword)
        .WithBindMount("../../.containers/mssql", "/var/opt/mssql/data");

var travelLoungeMsSqlCatalog = travelLoungeMsSql
    .AddDatabase("travellounge-mssql-catalog", "TravelLounge_Catalog");

Access to the database in the container app:

            app.AddSqlServerDbContext<ApplicationDbContext>("travellounge-mssql-catalog", configureDbContextOptions: options =>
            {
                options.UseSqlServer(sqlOptions =>
                {
                    sqlOptions.MigrationsAssembly(typeof(ApplicationDbContext).GetTypeInfo().Assembly.GetName().Name);
                });
                options.EnableSensitiveDataLogging();
            });

The managed identity is assigned as Entra admin to the SQL server but I have no idea what is missing and why the connection fails.

Packages used:

  • "Aspire.Hosting.Azure" Version="8.0.1"

  • "Aspire.Hosting.Azure.Sql" Version="8.0.1"

  • "Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-deploymentarea-integrationsIssues pertaining to Aspire Integrations packagesazureIssues associated specifically with scenarios tied to using Azure

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions