C#C
C#2w ago
Tandy

✅ Aspire EF Core Migrations - Deployment to Azure?

I've configured a .NET worker service to handle EF Core migrations based on https://aspire.dev/integrations/databases/efcore/migrations It works well in development. But how should I model the AppHost resource so that I can deploy it to Azure? What's the best practice? I currently have it deploying as an Azure Container App, but it's not stopping after migrations are finished. I think it might be more appropriate to configure it as an Azure Container App Job. Is there another approach to consider?

var migrations = builder.AddProject<Projects.Catalog_MigrationService>(ServiceConstants.ServiceNames.CatalogDatabaseMigrations)
    .WithReference(database)
    .WaitFor(database)
    .PublishAsAzureContainerApp((module, app) =>
    {
        app.Template.Scale.MinReplicas = 0;
        app.Template.Scale.MaxReplicas = 1;
    });
Was this page helpful?