Home / Databricks on Azure

Databricks on AzureCheat sheetIntermediate

MLflow models in Unity Catalog cheat sheet: registering, aliases instead of stages, grants and migrating from the workspace registry

Commands and fixes for models in Unity Catalog on Azure Databricks. Register with a signature, promote with aliases, grant EXECUTE, copy versions across catalogs and migrate off workspace registry stages.

Deepak Bhardwaj7 min read

Applies toAzure Databricks Premium with Unity Catalog, MLflow 2.8+ / MLflow 3, Databricks Runtime 13.3 LTS ML and above, Databricks CLI 0.200+

When you need this

Typical tickets: someone's training job fails with an authorization or signature error, a serving endpoint can't load models:/...@Champion, or code that calls transition_model_version_stage stopped working after the workspace moved to Unity Catalog. This page lists the calls, grants and fixes in the order you'll need them.

Rules that differ from the old workspace model registry:

  • Model names have three levels, catalog.schema.model. Use the catalog for the environment (dev, prod), not stages.
  • Stages are not supported. Promote by moving an alias such as Champion to a new version.
  • Every new model version needs a model signature.
  • ML workloads must run on dedicated access mode compute. DBR 15.4 LTS ML and above also supports dedicated group access mode.
  • Webhooks, email notifications and comments are not supported. Use audit logs for history.

Point MLflow at Unity Catalog

In MLflow 3 the default registry URI is already databricks-uc. On MLflow 2, the default is Unity Catalog only when the workspace default catalog is a Unity Catalog catalog and the cluster runs DBR 13.3 LTS or above. Set it explicitly so the code behaves the same everywhere:

import mlflow
mlflow.set_registry_uri("databricks-uc")

On non-ML runtimes (DBR 11.3 LTS and above), install the client first:

%pip install --upgrade "mlflow-skinny[databricks]"
dbutils.library.restartPython()

Register a model with a signature

import mlflow
from mlflow.models import infer_signature

mlflow.set_registry_uri("databricks-uc")

with mlflow.start_run():
    model.fit(X_train, y_train)
    signature = infer_signature(X_train, model.predict(X_train))
    mlflow.sklearn.log_model(
        model,
        name="model",                       # MLflow 2: artifact_path="model"
        signature=signature,
        input_example=X_train.head(5),
        registered_model_name="dev.ml_team.churn_model",
    )

Passing only input_example also works, because MLflow 2.5+ infers the signature from it. Databricks autologging records a signature as well.

To register a model that is already logged:

mlflow.register_model("runs:/<run_id>/model", "dev.ml_team.churn_model")

Aliases: promote and roll back

from mlflow import MlflowClient
client = MlflowClient()
name = "prod.ml_team.churn_model"

client.set_registered_model_alias(name, "Champion", 7)     # promote v7
mv = client.get_model_version_by_alias(name, "Champion")   # which version is live?
print(mv.version, mv.run_id)
client.set_registered_model_alias(name, "Champion", 6)     # roll back: move the alias
client.delete_registered_model_alias(name, "Challenger")

Load by alias or by version:

model = mlflow.pyfunc.load_model(f"models:/{name}@Champion")
model_v6 = mlflow.pyfunc.load_model(f"models:/{name}/6")

Warning

Batch jobs that load @Champion pick up the new version on their next run with no deploy step. Move the alias only after validation, and keep the previous version number in the change record so a rollback is a single set_registered_model_alias call.

Use the same pattern from a shell:

databricks registered-models get prod.ml_team.churn_model
databricks registered-models set-alias prod.ml_team.churn_model Champion 7
databricks model-versions list prod.ml_team.churn_model

Find versions

Search in Unity Catalog supports exact equality only. order_by, tag filters and name search aren't supported, so look up models by full name:

for mv in client.search_model_versions("name='prod.ml_team.churn_model'"):
    print(mv.version, mv.status, mv.run_id, mv.aliases)

client.get_registered_model("prod.ml_team.churn_model")

Promote from dev to prod

Copy the validated version into the prod catalog's model, then point the alias at it. The destination model is created if it doesn't exist:

mlflow.set_registry_uri("databricks-uc")
client = MlflowClient()

copied = client.copy_model_version(
    "models:/dev.ml_team.churn_model/12",
    "prod.ml_team.churn_model",
)
client.set_registered_model_alias("prod.ml_team.churn_model", "Champion", copied.version)

Run this as the service principal that owns the prod model, not as a person. Only the owner can set aliases.

Grants

Registered models are a type of function in Unity Catalog, so model-level grants use ON FUNCTION:

-- Let the training principal create models in a schema
GRANT USE CATALOG ON CATALOG prod TO `sp-ml-training`;
GRANT USE SCHEMA, CREATE MODEL ON SCHEMA prod.ml_team TO `sp-ml-training`;

-- Let consumers and serving identities load the model
GRANT USE CATALOG ON CATALOG prod TO `ml-consumers`;
GRANT USE SCHEMA ON SCHEMA prod.ml_team TO `ml-consumers`;
GRANT EXECUTE ON FUNCTION prod.ml_team.churn_model TO `ml-consumers`;

SHOW GRANTS ON FUNCTION prod.ml_team.churn_model;
Action Privilege needed (plus USE CATALOG and USE SCHEMA)
Create a registered model CREATE MODEL (or CREATE FUNCTION) on the schema
Create a new version Owner, or CREATE MODEL VERSION on the model
Set or delete aliases Owner of the model
Load or serve by alias/version EXECUTE on the model
Set or delete tags Owner, or APPLY TAG
Rename, delete, edit description Owner (rename also needs CREATE MODEL on the schema)

Through the REST API, the securable type is function:

databricks grants get function prod.ml_team.churn_model

Tip

Make a group or service principal the owner of every prod model. If a person owns the model and leaves, nobody can move the Champion alias until a metastore admin transfers ownership.

Migrate from the workspace model registry

Use copy_model_version(). The migration guide requires MLflow 3.4.0 or later. The source registry is the workspace registry, so set databricks here, not databricks-uc:

%pip install --upgrade "mlflow>=3.4.0"
dbutils.library.restartPython()

import mlflow
from mlflow import MlflowClient

mlflow.set_registry_uri("databricks")
client = MlflowClient(registry_uri="databricks")

copied = client.copy_model_version(
    "models:/churn_model/5",                 # workspace registry model/version
    "prod.ml_team.churn_model",              # Unity Catalog destination
)

Old versions logged without a signature are rejected. For the migration copy only (MLflow 3.4.0+), you can skip the check:

import os
os.environ["MLFLOW_SKIP_SIGNATURE_CHECK_FOR_UC_REGISTRY_MIGRATION"] = "true"

How the old concepts map:

Workspace registry Unity Catalog
Stage Production / Staging Alias (Champion, Challenger) plus a separate catalog per environment
Can read EXECUTE
Can edit CREATE MODEL VERSION and APPLY TAG
Can manage MANAGE
Webhooks Model event job triggers (preview), check availability
Comments Not supported; use descriptions and tags (max 50 tags per object)

Update code that loads models: change models:/churn_model/Production to models:/prod.ml_team.churn_model@Champion. Remove calls to transition_model_version_stage; they won't work against Unity Catalog.

Errors and fixes

Symptom Cause Fix
Registration fails asking for a signature Model logged without signature or input example Log again with signature= or input_example=
PERMISSION_DENIED on register Missing CREATE MODEL on the schema, or USE CATALOG/USE SCHEMA Grants above
Authorization error writing artifacts during registration Artifact upload path auth Set os.environ['MLFLOW_USE_DATABRICKS_SDK_MODEL_ARTIFACTS_REPO_FOR_UC'] = 'True' and retry
Load by alias fails for a job or endpoint Run-as identity lacks EXECUTE on the model GRANT EXECUTE ON FUNCTION ... to that principal
Setting the alias is denied Caller isn't the model owner Run as the owning service principal, or transfer ownership
Model not found, written as a two-part name Registry URI is still the workspace registry, or the name lacks the catalog set_registry_uri("databricks-uc") and use the three-level name
Model invisible in another workspace Workspace on a different metastore or region Same metastore: grant access. Another region or account: use Delta Sharing
Training fails on a standard access mode cluster ML workloads need dedicated compute Use dedicated (single user or group) access mode

Prevent it next time

  • Do promotions in a job running as a service principal, with validation, then copy_model_version, then the alias move. Nobody should promote from a notebook.
  • Give every prod model a group or service principal owner, and grant EXECUTE to groups, not individuals.
  • Put mlflow.set_registry_uri("databricks-uc") in your shared training template so MLflow 2 and 3 clusters behave the same way.
  • Log the alias-to-version mapping before and after each promotion so a rollback is a single command.