Get access to the AML job which runs the current Python code.

Jaume Amores 25 Reputation points
2025-11-19T05:24:52.4033333+00:00

Hello!

I would like to get access to the job running the current Python code. I know it is possible using mlflow if I know the run_id, as follows:

this_job = client.jobs.get(run_id)


How can I do it without knowing the run_id ? Ideally, without knowing any job details, so that Azure ML figures out which is the job running the code and retrieves a handle to it.

Thanks!

Jaume

Azure Machine Learning
{count} votes

Answer accepted by question author
  1. Anshika Varshney 3,885 Reputation points Microsoft External Staff Moderator
    2025-11-19T07:25:33.7766667+00:00

    Hi Jaume Amores,

    Thanks for the question.

    If you want to access the job that is currently running your pipeline, Azure ML doesn’t provide a direct “get current job” command during execution. However, you can still access the job information in a couple of easy ways.

    1. Use environment variables inside the job When a job is running, Azure ML automatically injects variables like the run ID and job name. For example, in Python you can get them like this:

    import os
    print(os.getenv("AZUREML_RUN_ID"))
    print(os.getenv("AZUREML_JOB_NAME"))
    

    You can then use these values to query more job details using the MLClient.

    2. Use the Azure ML SDK to fetch job details If you know the job name or run ID, you can retrieve full information:

    job = ml_client.jobs.get(job_name)
    print(job.status)
    

    3. Check the portal You can always open Azure ML Studio → Jobs to see the run that executed your pipeline, including logs, outputs, and metadata.

    Hope this helps! Let me know if you need any further assistance.

    Thankyou!

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.