How to fix model logging in MLFlow?

Gustavo Carmo 30 Reputation points
2025-06-29T15:17:05.4866667+00:00

Hi.

I am getting a 404 when logging models using MLFlow:

...
    os.environ["MLFLOW_TRACKING_URI"] = workspace.mlflow_tracking_uri
...
    mlflow.pytorch.log_model(
        pytorch_model=dummy_model,
        name="simple_pytorch_model",
        signature=signature,
        input_example=dummy_input.numpy()
    )

The error message is: mlflow.exceptions.MlflowException: API request to endpoint /api/2.0/mlflow/logged-models failed with error code 404 != 200. Response body: ''

This is being performed towards the westus3 region and the workspace has been created in May of 2024.

Is this API currently supported/supposed to be working?

Thank you

Azure Machine Learning
{count} votes

Answer accepted by question author
  1. Jerald Felix 9,920 Reputation points
    2025-06-29T16:37:56.66+00:00

    Hi Gustavo Carmo

    I ran into the same 404 error last week and it turned out to be a simple client-vs-server version mismatch.

    Why it’s happening

    MLflow 2.8 (and anything newer) added a “logged-model” API. When you pass a name= argument to mlflow.pytorch.log_model() (or any log_model call), the client tries to hit /api/2.0/mlflow/logged-models/*. Azure ML workspaces are still running an MLflow server ≤ 2.7, which only understands the older /registered-models/* routes. The server doesn’t recognise the new endpoint and sends back a 404.


    Two quick ways to unblock your run

    Downgrade the clientbash<br>pip install "mlflow<2.8"<br># e.g. mlflow==2.7.1<br>Your script keeps the one-step “log + register” flow and the server responds with 200.

    Keep the new client, skip the new API

    Drop the name= parameter, then register in a second line: python mlflow.pytorch.log_model( pytorch_model=model, artifact_path="simple_pytorch_model" ) run_uri = f"runs:/{mlflow.active_run().info.run_id}/simple_pytorch_model" mlflow.register_model(run_uri, "simple_pytorch_model")

    With no name=, the client falls back to the classic workflow the server already supports.

    Tip: Inside an Azure ML job you don’t need to set MLFLOW_TRACKING_URI; the runtime injects the correct azureml://… value automatically. Using the HTTPS URI from the portal can also trigger 404s.


    Quick checklist if it still fails

    python -m pip show mlflow — confirm the version you expect.

    az ml workspace show -n <name> — check the region; rollouts happen region by region.

    az ml job create ... in a fresh venv after pinning MLflow < 2.8.

    Still 404? Grab the request ID from the error, share a minimal repro notebook to Q and A support here to create suppor ticket —they can confirm whether your workspace has the newer server build yet.

    Once the backend upgrades past MLflow 2.8 you can go back to the latest client and the single-line log_model(name=…) call will work again.

    Hope that helps—shout if you get stuck!

    Best Regards,

    Jerald Felix

    5 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Alert101 5 Reputation points
    2025-07-27T11:46:40.5166667+00:00

    I came across this as well. Fixed it in Azure ML Studio by pinning the mlflow-skinny package to an earlier version in my requirements.yml file. The combination below works. Without pinning mlflow-skinny Azure MLS will install 3.1.4 which doesn't work.

      - pip:
          - azureml-mlflow==1.60.0
          - azure-ai-ml==1.27.1
          - mlflow-skinny==3.1.1
    

    Ref: https://github.com/mlflow/mlflow/issues/16215

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.