Use private Python packages with Azure Machine Learning - PAT Auth

G Cocci 211 Reputation points Microsoft Employee
2021-02-25T14:37:02.737+00:00

Hi,

I am trying to deploy a model on an AKS cluster in Azure Machine Learning that uses a Python package that is present as a package in a feed on Azure DevOps.
I found the following article that explains how to do this:

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-private-python-packages

In the example it shows that in the Worspace.set_connection method, it passes a string as "value".
If I try to do the same in my code the following error appears:

azureml._base_sdk_common.workspace.models.machine_learning_service_error.MachineLearningServiceErrorException: (ValidationError) JSON format is expected for Properties.Value

Looking at the documentation (azureml.core.workspace.workspace) it actually says that it expects a JSON:
value: the json format serialization string of the connection details)

What format and what information should this JSON contain?

Thanks,
G.

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,580 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ramr-msft 17,616 Reputation points
    2021-02-26T10:02:41.517+00:00

    @G Cocci Thanks for the question. Please find the example for PAT passing.

    from azureml.core import Workspace  
      
    pat_token = input("Enter secret token")  
    ws = Workspace.from_config()  
    ws.set_connection(name="connection-1",   
       category = "PythonFeed",  
       target = "https://<my-org>.pkgs.visualstudio.com",   
       authType = "PAT",   
       value = “\’”+pat_token+”\’”)   
    

    https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-private-python-packages#use-a-repository-of-packages-from-azure-devops-feed

    0 comments No comments