Update Umbraco Schema From Data Files automatically

Hello,
We are going to have a lot of child projects under our baseline project.
I have a problem where the Umbraco schema is not updated after deployment until “Update Umbraco schema” has been run.
Is there a way to run “Update Umbraco schema” automatically / programmatically?

Thanks in advance!

Hi @marc3137 ,

As far as I’m aware, Umbraco Cloud should deploy schema changes automatically so I’d raise this with Umbraco Cloud support. If the schema isn’t auto-applying on baseline merges, that’s an Umbraco Cloud issue rather than something you should need to fix or work around. They can check the deployment logs on their side and confirm whether the Deploy trigger is actually firing.

Justin

1 Like

Hey @justin-nevitech Thanks for the reply. I have been in contact with support ant they admit its a known error. I was just hoping someone might have found a workaround or a way to solve it

Hi @marc3137

These are some suggestions from AI if any of these help you?

1. Trigger via the Umbraco Deploy Management API (Recommended)

Umbraco Deploy exposes a REST API you can call as part of your deployment pipeline (e.g. a post-deployment script, GitHub Action, Azure DevOps task, etc.).

POST to trigger a schema update from UDA files:

POST https://{your-environment}.umbraco.io/umbraco/deploy/api/v1/deploy
Authorization: Bearer {token}
Content-Type: application/json

{
  "type": "schema"
}

You’ll need to authenticate using an Umbraco Cloud API key or a backoffice user token. The Deploy Management API uses the same auth as the Umbraco Management API (/umbraco/management/api/v1/security/back-office/token).


2. Auto-restore on Startup via appsettings.json

Umbraco Deploy has a setting to automatically apply UDA files on application startup:

json

"Umbraco": {
  "Deploy": {
    "Settings": {
      "AllowRestoreOnStartup": true
    }
  }
}

This is the most “hands-off” approach — every time the app starts after a deployment, it will automatically process pending schema changes. Be aware this adds startup time and could be a concern on shared/slow environments.


3. Programmatically via a Notification Handler

If you need more control (e.g. only run it under certain conditions), you can hook into UmbracoApplicationStartedNotification and call the Deploy service directly:

csharp

public class DeployOnStartupHandler 
    : INotificationAsyncHandler<UmbracoApplicationStartedNotification>
{
    private readonly IDeployService _deployService;

    public DeployOnStartupHandler(IDeployService deployService)
        => _deployService = deployService;

    public async Task HandleAsync(
        UmbracoApplicationStartedNotification notification, 
        CancellationToken cancellationToken)
    {
        await _deployService.DeployAsync(
            new[] { "$all" }, // deploy all schema
            DeploySelector.SchemaAndContent, // or SchemaOnly
            cancellationToken: cancellationToken);
    }
}

Register it in Startup.cs / Program.cs:

csharp

builder.CreateUmbracoBuilder()
    .AddBackOffice()
    .AddWebsite()
    .AddDeliveryApi()
    .AddCompose()
    .AddNotificationAsyncHandler<UmbracoApplicationStartedNotification, DeployOnStartupHandler>()
    .Build();

I don’t know if any of these suggestions would work for you?

Justin