Skip to content

azure-ai-ml get_datastore_info() raises traced HttpResponseError for identity-based datastores #44636

@happywhaler

Description

@happywhaler

what

When using download_artifact_from_aml_uri() with a datastore configured for identity-based access (no stored credentials), the SDK internally raises an HttpResponseError that gets caught and handled correctly, but the exception is still captured by OpenTelemetry tracing. This causes noisy error traces in Application Insights even though the operation succeeds.

To Reproduce

Configure an Azure ML datastore with identity-based access (no account key or SAS token stored)
Enable OpenTelemetry tracing (e.g., via azure-monitor-opentelemetry)
Download an artifact using download_artifact_from_aml_uri()

from azure.ai.ml import MLClient
import azure.ai.ml._artifacts._artifact_utilities as artifact_utils

ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group, workspace)
artifact_utils.download_artifact_from_aml_uri(
    uri="azureml://subscriptions/.../datastores/mystore/paths/data.csv",
    destination="/tmp/output",
    datastore_operation=ml_client.datastores
)

Expected behavior

The download succeeds (which it does), but no exception should appear in traces since this is expected behavior for identity-based datastores.

Actual behavior

The download succeeds, but an exception trace is recorded:

azure.core.exceptions.HttpResponseError: (UserError) No secrets for credentials of type None.
Code: UserError
Message: No secrets for credentials of type None.

Root cause

In _artifact_utilities.py, get_datastore_info() uses a try/except pattern:

try:
    credential = operations._list_secrets(name=name, expirable_secret=True)
    datastore_info["credential"] = credential.sas_token
except HttpResponseError:
    datastore_info["credential"] = operations._credential

Maybe consider one of:

  • Check datastore.credentials type before calling _list_secrets() to avoid the exception entirely
  • Return an empty/null credential from _list_secrets() instead of raising for identity-based datastores

Environment

azure-ai-ml version: 1.30.0
Python version: 3.12
OS: Linux (Azure Container Apps)
Tracing: azure-monitor-opentelemetry

Metadata

Metadata

Labels

Machine LearningService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions