'AzureML model deployment: How to programatically authenticate to ACR for use in Model.deploy()

The Model.deploy python function for AzureML deploys a model as an endpoint. But first it builds a docker image for deployment. If I run this in an AzureML notebook it all works fine.

However, if I try and run this in a local Jupyter notebook then I get authentication required when it tries to login to the container registry. If I use the AZ ACR LOGIN cli command then it works as expected.

However, I am trying to write an unattended service that uses service principal credentials. I have tried using both the ACR SDK and the Docker SDK to programatically login to my registry but these are both ignored by Model.deploy. It seems like it only respects (or docker does) the cached credentials in the docker config

So, how can I get around this, is it possible to programatically login to the registry for the benefit of Model.deploy or do I have to rely on cached credentials, and if so, then is it possible then to programatically add to the cached credentials on the machine?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source