{"id":6536,"library":"azureml-sdk","title":"Azure Machine Learning SDK (v1)","description":"The Azure Machine Learning SDK v1 (meta-package for `azureml-core`) is used to build and run machine learning workflows upon the Azure Machine Learning service. It enables managing cloud resources, training models, and deploying them as web services. As of March 31, 2025, SDK v1 has been deprecated, with support ending on June 30, 2026. Users are strongly advised to migrate to Azure Machine Learning Python SDK v2 (`azure-ai-ml`) for continued support and new features.","status":"deprecated","version":"1.62.0","language":"en","source_language":"en","source_url":"https://learn.microsoft.com/en-us/python/api/overview/azure/ml/","tags":["Azure","Machine Learning","MLOps","cloud","deprecated","v1"],"install":[{"cmd":"pip install azureml-sdk","lang":"bash","label":"Install Azure ML SDK v1"}],"dependencies":[],"imports":[{"note":"Used to connect to your Azure ML workspace.","symbol":"Workspace","correct":"from azureml.core import Workspace"},{"note":"Used to create and manage ML experiments.","symbol":"Experiment","correct":"from azureml.core import Experiment"},{"note":"Used to define the reproducible Python environment for runs and deployments.","symbol":"Environment","correct":"from azureml.core import Environment"},{"note":"Encapsulates the script, compute target, and environment for a training run.","symbol":"ScriptRunConfig","correct":"from azureml.core import ScriptRunConfig"},{"note":"ComputeTarget is typically imported from the `azureml.core.compute` submodule, not directly from `azureml.core`.","wrong":"from azureml.core import ComputeTarget","symbol":"ComputeTarget","correct":"from azureml.core.compute import ComputeTarget"}],"quickstart":{"code":"import os\nfrom azureml.core import Workspace, Experiment, Environment, ScriptRunConfig\nfrom azureml.core.compute import ComputeTarget, AmlCompute\nfrom azureml.core.compute_target import ComputeTargetException\nfrom azureml.core.conda_dependencies import CondaDependencies\n\n# Create a dummy script file\nwith open('train_script.py', 'w') as f:\n    f.write(\"\"\"\nimport argparse\nimport os\nimport time\nprint(\"Hello from Azure ML v1 training script!\")\nparser = argparse.ArgumentParser()\nparser.add_argument('--arg1', type=str, default='default_value')\nargs = parser.parse_args()\nprint(f\"Argument 1: {args.arg1}\")\ntime.sleep(5) # Simulate work\nprint(\"Script finished.\")\n\"\"\")\n\n# Create a dummy conda environment file\nwith open('conda_env.yml', 'w') as f:\n    f.write(\"\"\"\nname: my_env\ndependencies:\n  - python=3.8\n  - pip:\n    - azureml-defaults\n\"\"\")\n\n# NOTE: For a real scenario, replace placeholder values and ensure a config.json is available\n# Authenticate and connect to your workspace\ntry:\n    ws = Workspace.from_config(path='./.azureml', _file_name='config.json') # Reads from a local config.json\n    print(f\"Connected to workspace {ws.name}\")\nexcept Exception as e:\n    print(f\"Could not load workspace from config. Ensure .azureml/config.json exists or provide details manually: {e}\")\n    # Fallback to manual connection (replace with your actual details)\n    subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID')\n    resource_group = os.environ.get('AZURE_RESOURCE_GROUP', 'YOUR_RESOURCE_GROUP')\n    workspace_name = os.environ.get('AZURE_WORKSPACE_NAME', 'YOUR_WORKSPACE_NAME')\n    ws = Workspace(subscription_id, resource_group, workspace_name)\n    print(f\"Connected to workspace {ws.name} via manual details.\")\n\nexperiment_name = \"my-first-v1-experiment\"\nexperiment = Experiment(workspace=ws, name=experiment_name)\n\n# Choose a name for your CPU cluster (or use 'local')\ncompute_name = \"cpu-cluster\"\ncompute_target = None\n\ntry:\n    compute_target = ComputeTarget(workspace=ws, name=compute_name)\n    print(f\"Found existing compute target: {compute_name}\")\nexcept ComputeTargetException:\n    print(f\"Creating a new compute target: {compute_name}\")\n    compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_DS1_V2', max_nodes=1)\n    compute_target = ComputeTarget.create(ws, compute_name, compute_config)\n    compute_target.wait_for_completion(show_output=True)\n\n# Define the environment\nenv = Environment.from_conda_specification(name='my-custom-env', file_path='conda_env.yml')\n\n# Create a ScriptRunConfig\nsrc = ScriptRunConfig(\n    source_directory='.',\n    script='train_script.py',\n    compute_target=compute_target,\n    environment=env,\n    arguments=['--arg1', 'hello_from_run']\n)\n\n# Submit the run\nrun = experiment.submit(src)\nprint(f\"Submitted run: {run.get_portal_url()}\")\nrun.wait_for_completion(show_output=True)\nprint(f\"Run completed with status: {run.status}\")\n","lang":"python","description":"This quickstart demonstrates how to connect to an Azure ML Workspace, define a custom environment, create a compute target (or use 'local'), and submit a simple Python script as an experiment using `ScriptRunConfig` in Azure ML SDK v1. A `config.json` file in a `.azureml` subdirectory is the recommended way to connect to a workspace."},"warnings":[{"fix":"Migrate your workflows to the Azure Machine Learning Python SDK v2 (`azure-ai-ml`). This involves significant API changes; refer to the official migration guides.","message":"Azure Machine Learning SDK v1 is officially deprecated as of March 31, 2025, with end of support on June 30, 2026. After this date, existing workflows may still run but will not receive technical support or updates, potentially exposing them to security risks or breaking changes.","severity":"breaking","affected_versions":"All versions of azureml-sdk (v1)"},{"fix":"Use separate Python environments for SDK v1 and SDK v2 projects. If mixed interaction with a single workspace is needed, ensure distinct environments for each SDK version.","message":"SDK v1 (`azureml-sdk`) and SDK v2 (`azure-ai-ml`) are incompatible and should generally not be installed in the same Python environment to avoid package clashes and confusion.","severity":"gotcha","affected_versions":"All versions when used with SDK v2"},{"fix":"Ensure a valid `config.json` file is present in the default search path (`.azureml/`) or specify the workspace details directly. For interactive authentication, follow the browser prompts. For automated scripts, consider service principal authentication.","message":"Authentication to an Azure ML Workspace in v1 often relies on a `config.json` file (containing subscription ID, resource group, and workspace name) placed in a `.azureml` subdirectory or explicitly passed parameters. Without proper configuration, connection attempts will fail. Interactive authentication is also common for initial setup.","severity":"gotcha","affected_versions":"All v1 versions"},{"fix":"Prefer `ScriptRunConfig` for submitting training jobs in SDK v1. When migrating to SDK v2, `Command` jobs are the direct equivalent.","message":"`Estimator` classes, a common way to define training jobs in earlier v1 versions, are effectively superseded by `ScriptRunConfig` and later `Command` (in v2). While still functional in v1, `ScriptRunConfig` offers more flexibility.","severity":"deprecated","affected_versions":"Earlier v1 versions using Estimator"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}