Hello, I've been trying to make a machine learning pipeline in azure python sdk v2, where I want to download some models inside the pipeline.
This is the code I've used so far:
# Create ml_client
subscription_id = "..."
resource_group = "..."
workspace_name = "..."
ml_client = MLClient(
DefaultAzureCredential(),
subscription_id,
resource_group,
workspace_name,
)
model_name = '...'
download_path = '...'
ml_client.models.download(name=model_name, version=1, download_path=download_path)
But when I run it as a pipeline, I get the following error message:
DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
ManagedIdentityCredential: No token received.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
Cleaning up all outstanding Run operations, waiting 300.0 seconds
0 items cleaning up...
Cleanup took 7.152557373046875e-07 seconds
Traceback (most recent call last):
File "Scripts/deploy_assess.py", line 123, in <module>
download_model(model_name, model_path)
File "Scripts/deploy_assess.py", line 111, in download_model
ml_client.models.download(name=model_name, version=1, download_path=download_path)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 263, in wrapper
return f(*args, **kwargs)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/operations/_model_operations.py", line 316, in download
model_uri = self.get(name=name, version=version).path
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/_telemetry/activity.py", line 263, in wrapper
return f(*args, **kwargs)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/operations/_model_operations.py", line 301, in get
model_version_resource = self._get(name, version)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/operations/_model_operations.py", line 247, in _get
else self._model_versions_operation.get(
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
return func(*args, **kwargs)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/ai/ml/_restclient/v2023_04_01_preview/operations/_model_versions_operations.py", line 563, in get
pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 213, in run
return first_node.send(pipeline_request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
[Previous line repeated 2 more times]
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/mgmt/core/policies/_base.py", line 46, in send
response = self.next.send(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/policies/_redirect.py", line 181, in send
response = self.next.send(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/policies/_retry.py", line 467, in send
response = self.next.send(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 113, in send
self.on_request(request)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/core/pipeline/policies/_authentication.py", line 90, in on_request
self._token = self._credential.get_token(*self._scopes)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/identity/_credentials/default.py", line 214, in get_token
return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
File "/azureml-envs/azureml_4bed098370e0b93d72c499e8bdcce325/lib/python3.10/site-packages/azure/identity/_credentials/chained.py", line 111, in get_token
raise ClientAuthenticationError(message=message)
azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
ManagedIdentityCredential: No token received.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
The websites the error message redirects me to were of no help...