How do you create an ML Environment in an AML registry, using a custom, pre built docker image residing in a private ACR

Chris Musselle 0 Reputation points
2025-02-17T15:48:10.01+00:00

I am trying to create a reusable ML Environment for use by multiple AML workspaces by creating one in an AML registry. However, this Environment needs to be based off a custom docker image that I create in a previous step. Reason being, as part of creating this docker image, I need to make use of build arguments and build secrets which are passed as part of the docker cli command. The documentation says that it should be possible to create such an environment using an existing docker image, but I can't get this working when the image is in a private ACR.

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-manage-environments-v2?view=azureml-api-2&tabs=python#create-an-environment-from-a-docker-image

Things I have tried:

  • Using a docker build context and building the docker image as an ACR task. This works with a minimal test image, but I am unable to pass in additional build arguments or secrets, so can't use this approach with my custom image.
  • Running the example in the docs, using the az cli, but referencing a private ACR in the image url. This appeared to result in the command trying to lookup the image in dockerhub, as it gave the following error:
    • cli.azure.cli.core.azclierror: (UserError) Authentication failed for container registry docker.io
  • Running the example in the docs, using the python SDK but referencing a private ACR in the image url. This looking like it tried to connect to the private ACR, but could not authenticate.
    • HttpResponseError: (UserError) Authentication failed for container registry myprivateacr.azurecr.io
  • I retried both of the above after giving the AML registry identity the AcrPull role on the private ACR. This did not resolve the issue.
  • Treating the AML registry like a regular AML workspace, and trying to add a connection object to the registry using the admin username and password for the ACR. This did not work as I don't think AML registry objects have the same concept as connections. I received the below error during the request serialisation step:
    • ValueError: No value for given attribute

Version info:

  • Python: 3.12
  • azure.ai.ml: 1.25.0
  • azure cli: 2.69.0
  • azure cli ml extension: 2.33.1

Any help getting this working would be greatly appreciated.

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,141 questions
{count} votes

Your answer

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