次の方法で共有


ワークスペース診断を使う方法

適用対象: Python SDK azure-ai-ml v2 (現行)

適用対象:Azure Machine Learning SDK v1 for Python

重要

この記事では、Azure Machine Learning SDK v1 の使用に関する情報を提供します。 SDK v1 は 2025 年 3 月 31 日の時点で非推奨となり、サポートは 2026 年 6 月 30 日に終了します。 SDK v1 は、その日付までインストールして使用できます。

2026 年 6 月 30 日より前に SDK v2 に移行することをお勧めします。 SDK v2 の詳細については、「 Azure Machine Learning Python SDK v2SDK v2 リファレンスとは」を参照してください。

Azure Machine Learning には、ワークスペースの問題を特定するために使用できる診断 API が提供されています。 診断レポートで返されるエラーには、問題の解決方法に関する情報が含まれています。

Azure Machine Learning スタジオまたは Python SDK からワークスペース診断を使用できます。

前提条件

  • Azure Machine Learning ワークスペース。 ワークスペースを作成する手順については、「ワークスペースの 作成」を参照してください。

  • Azure Machine Learning SDK for Python v2。 SDK をインストールするには、次のコマンドを使用します。

    pip install azure-ai-ml azure-identity
    

    SDK の既存のインストールを最新バージョンに更新するには、次のコマンドを使用します。

    pip install --upgrade azure-ai-ml azure-identity
    

    詳細については、「 Python 用 Azure Machine Learning パッケージ クライアント ライブラリ」を参照してください。

Studio からの診断

Azure Machine Learning スタジオから、ワークスペースの診断を実行して、セットアップを確認することができます。 診断を実行するには、ページの右上隅にある [?] アイコンを選択します。 次に、 [Run workspace diagnostics](ワークスペース診断の実行) を選択します。

ワークスペース診断ボタンのスクリーンショット。

診断の実行後、検出された問題の一覧が返されます。 この一覧には、考えられる解決策へのリンクが含まれています。

Python からの診断

次のスニペットは、Python からワークスペースの診断を使う方法を示しています。

適用対象: Python SDK azure-ai-ml v2 (現行)

from azure.ai.ml import MLClient
from azure.ai.ml.entities import Workspace
from azure.identity import DefaultAzureCredential

subscription_id = '<your-subscription-id>'
resource_group = '<your-resource-group-name>'
workspace = '<your-workspace-name>'

ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group)
resp = ml_client.workspaces.begin_diagnose(workspace).result()
# Inspect the attributes of the response you are interested in
for result in resp.application_insights_results:
    print(f"Diagnostic result: {result.code}, {result.level}, {result.message}")

応答は、ワークスペースで検出されたすべての問題に関する情報を含む DiagnoseResponseResultValue オブジェクトです。

適用対象:Azure Machine Learning SDK v1 for Python

from azureml.core import Workspace

ws = Workspace.from_config()

diag_param = {
      "value": {
      }
    }

resp = ws.diagnose_workspace(diag_param)
print(resp)

応答は、ワークスペースで検出されたすべての問題に関する情報を含む JSON ドキュメントです。 次の JSON は応答の例です。

{
    "value": {
        "user_defined_route_results": [],
        "network_security_rule_results": [],
        "resource_lock_results": [],
        "dns_resolution_results": [{
            "code": "CustomDnsInUse",
            "level": "Warning",
            "message": "It is detected VNet '/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Network/virtualNetworks/<virtual-network-name>' of private endpoint '/subscriptions/<subscription-id>/resourceGroups/<myresourcegroup>/providers/Microsoft.Network/privateEndpoints/<workspace-private-endpoint>' is not using Azure default DNS. You need to configure your DNS server and check https://learn.microsoft.com/azure/machine-learning/how-to-custom-dns to make sure the custom DNS is set up correctly."
        }],
        "storage_account_results": [],
        "key_vault_results": [],
        "container_registry_results": [],
        "application_insights_results": [],
        "other_results": []
    }
}

問題が検出されない場合は、空の JSON ドキュメントが返されます。

詳細については、ワークスペースに関するリファレンスを参照してください。

詳細については、Workspace.diagnose_workspace() のリファレンスを参照してください。

次のステップ