mltable client insists on using interactive authentication

158 views Asked by At

I can't get the mltable client to stop using interactive authentication to load or save data. The folowing code:

registered_data_asset = ml_client.data.get(
    'Dataset',
    label='latest')
            
tbl = mltable.load(f'azureml:/{registered_data_asset.id}')

Results in the prompt:

Performing interactive authentication. Please follow the instructions on the terminal.
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.

I can't use interactive authentication for my use case, I need authentication through environment variables. And this should work because mlclient is able to use environment authentication.

I have AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID in my environment vars. I also looked at Azure tableclient in console app using interactive authentication and I've made sure that my app registration has the role Storage Table Data Contributor from the store account that I use for mltables.

It seems that the issue arises when a method from the Copier class from azureml.dataprep.rslex is called. But this class is a built-in so I can't really determine what is going on.

Does anyone know how to get mltable to stop using interactive authentication?

2

There are 2 answers

0
petrovski On BEST ANSWER

Turns out to have been a bug which was fixed in mltable == 1.6.1 https://pypi.org/project/mltable/1.6.1/

5
Venkatesan On

Does anyone know how to get mltable to stop using interactive authentication?

You can use the below code to get the mltable with clientsecretcredential authentication using Python SDK.

Code:

import mltable
from azure.ai.ml import MLClient
from azure.identity import ClientSecretCredential

subscription_id="xxxx"
resource_group="xxxx"
workspace="xxxx"
VERSION="xxxx"
credential=ClientSecretCredential(tenant_id="xxxx",client_id="xxx",client_secret="xxxx")
ml_client = MLClient(credential, subscription_id, resource_group, workspace)
data_asset = ml_client.data.get(name="data098", version=VERSION)
tbl = mltable.load(f"azureml:/{data_asset.id}")
df=tbl.to_pandas_dataframe()
df.head(8)

The ClientSecretCredential object is used to authenticate the application with appropriate values for the tenant ID, client ID, and client secret.

Output:

enter image description here

Reference:

azure.identity.ClientSecretCredential class | Microsoft Learn