Is Azure Machine Learning Python SDK v1 still supported

ZHANG, JINGLIANG 1 Reputation point
2023-05-10T18:34:41.15+00:00

I followed this page and example (section "Service Principal Authentication")

https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb

import os
from azureml.core.authentication import ServicePrincipalAuthentication

svc_pr_password = os.environ.get("AZUREML_PASSWORD")

svc_pr = ServicePrincipalAuthentication(
    tenant_id="my-tenant-id",
    service_principal_id="my-application-id",
    service_principal_password=svc_pr_password)


ws = Workspace(
    subscription_id="my-subscription-id",
    resource_group="my-ml-rg",
    workspace_name="my-ml-workspace",
    auth=svc_pr
    )

print("Found workspace {} at location {}".format(ws.name, ws.location))

The print works fine. However, when I try to get datastore like below, it times out after 60sec. Why is that?

print(ws.datastores)

>>>
.
.

  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/core/workspace.py", line 1102, in datastores
    datastore.name: datastore for datastore in _DatastoreClient.list(self)}
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/data/datastore_client.py", line 668, in list
    dss, ct = _DatastoreClient._list(workspace, ct, 100)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/data/_exception_handler.py", line 16, in decorated
    return f(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/data/datastore_client.py", line 938, in _list
    client = _DatastoreClient._get_client(ws, auth, host)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/data/datastore_client.py", line 977, in _get_client
    host = host or host_env or get_service_url(
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 120, in get_service_url
    return cached_service_object.get_cached_service_url(workspace_scope, service_name,
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 282, in get_cached_service_url
    return self.get_cached_services_uris(arm_scope, service_name, unique_id=unique_id,
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 182, in wrapper
    return test_function(self, *args, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 257, in get_cached_services_uris
    cache[cache_key][DEFAULT_FLIGHT] = super(CachedServiceDiscovery, self).discover_services_uris_from_arm_scope(arm_scope, discovery_url)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 138, in discover_services_uris_from_arm_scope
    return self.discover_services_uris(discovery_url)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_base_sdk_common/service_discovery.py", line 141, in discover_services_uris
    status = ClientBase._execute_func(requests.get, discovery_url)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_restclient/clientbase.py", line 375, in _execute_func
    return cls._execute_func_internal(
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_restclient/clientbase.py", line 368, in _execute_func_internal
    left_retry = cls._handle_retry(back_off, left_retry, total_retry, error, logger, func)
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_restclient/clientbase.py", line 400, in _handle_retry
    raise error
  File "/opt/anaconda3/lib/python3.9/site-packages/azureml/_restclient/clientbase.py", line 359, in _execute_func_internal
    response = func(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/opt/anaconda3/lib/python3.9/site-packages/requests/adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(60, 'Operation timed out'))

I tried SDK v2 and I can access datastore. Configuration like tenant_id, service principal id/password, subscriptionid, resourcegroup, workspace_name are the same.


ml_client = MLClient.from_config(credential=credential)
.
.
print(ml_client.datastores.get("workspaceblobstore"))

>>>
AzureBlobDatastore({'type': <DatastoreType.AZURE_BLOB: 'AzureBlob'>, 'name': 'workspaceblobstore', 'descriptio
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,579 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ZHANG, JINGLIANG 1 Reputation point
    2023-05-15T13:14:47.99+00:00

    @romungi no. it returns the same time out. turns out the issue is my local network.

    0 comments No comments