[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-c91ee933-b953-4ae0-81f5-3f5a61ecf5dc":3,"$fYEOT7wrcxX3Sxshavp90BgwD8KCcnizjyvzXXAxtdZw":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"c91ee933-b953-4ae0-81f5-3f5a61ecf5dc","azure-ai-ml-py","Azure机器学习SDK v2 for Python。用于ML工作区、作业、模型、数据集、计算和管道。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-ai-ml-py\ndescription: Azure Machine Learning SDK v2 for Python. Use for ML workspaces, jobs, models, datasets, compute, and pipelines.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure Machine Learning SDK v2 for Python\n\nClient library for managing Azure ML resources: workspaces, jobs, models, data, and compute.\n\n## Installation\n\n```bash\npip install azure-ai-ml\n```\n\n## Environment Variables\n\n```bash\nAZURE_SUBSCRIPTION_ID=\u003Cyour-subscription-id>\nAZURE_RESOURCE_GROUP=\u003Cyour-resource-group>\nAZURE_ML_WORKSPACE_NAME=\u003Cyour-workspace-name>\n```\n\n## Authentication\n\n```python\nfrom azure.ai.ml import MLClient\nfrom azure.identity import DefaultAzureCredential\n\nml_client = MLClient(\n    credential=DefaultAzureCredential(),\n    subscription_id=os.environ[\"AZURE_SUBSCRIPTION_ID\"],\n    resource_group_name=os.environ[\"AZURE_RESOURCE_GROUP\"],\n    workspace_name=os.environ[\"AZURE_ML_WORKSPACE_NAME\"]\n)\n```\n\n### From Config File\n\n```python\nfrom azure.ai.ml import MLClient\nfrom azure.identity import DefaultAzureCredential\n\n# Uses config.json in current directory or parent\nml_client = MLClient.from_config(\n    credential=DefaultAzureCredential()\n)\n```\n\n## Workspace Management\n\n### Create Workspace\n\n```python\nfrom azure.ai.ml.entities import Workspace\n\nws = Workspace(\n    name=\"my-workspace\",\n    location=\"eastus\",\n    display_name=\"My Workspace\",\n    description=\"ML workspace for experiments\",\n    tags={\"purpose\": \"demo\"}\n)\n\nml_client.workspaces.begin_create(ws).result()\n```\n\n### List Workspaces\n\n```python\nfor ws in ml_client.workspaces.list():\n    print(f\"{ws.name}: {ws.location}\")\n```\n\n## Data Assets\n\n### Register Data\n\n```python\nfrom azure.ai.ml.entities import Data\nfrom azure.ai.ml.constants import AssetTypes\n\n# Register a file\nmy_data = Data(\n    name=\"my-dataset\",\n    version=\"1\",\n    path=\"azureml:\u002F\u002Fdatastores\u002Fworkspaceblobstore\u002Fpaths\u002Fdata\u002Ftrain.csv\",\n    type=AssetTypes.URI_FILE,\n    description=\"Training data\"\n)\n\nml_client.data.create_or_update(my_data)\n```\n\n### Register Folder\n\n```python\nmy_data = Data(\n    name=\"my-folder-dataset\",\n    version=\"1\",\n    path=\"azureml:\u002F\u002Fdatastores\u002Fworkspaceblobstore\u002Fpaths\u002Fdata\u002F\",\n    type=AssetTypes.URI_FOLDER\n)\n\nml_client.data.create_or_update(my_data)\n```\n\n## Model Registry\n\n### Register Model\n\n```python\nfrom azure.ai.ml.entities import Model\nfrom azure.ai.ml.constants import AssetTypes\n\nmodel = Model(\n    name=\"my-model\",\n    version=\"1\",\n    path=\".\u002Fmodel\u002F\",\n    type=AssetTypes.CUSTOM_MODEL,\n    description=\"My trained model\"\n)\n\nml_client.models.create_or_update(model)\n```\n\n### List Models\n\n```python\nfor model in ml_client.models.list(name=\"my-model\"):\n    print(f\"{model.name} v{model.version}\")\n```\n\n## Compute\n\n### Create Compute Cluster\n\n```python\nfrom azure.ai.ml.entities import AmlCompute\n\ncluster = AmlCompute(\n    name=\"cpu-cluster\",\n    type=\"amlcompute\",\n    size=\"Standard_DS3_v2\",\n    min_instances=0,\n    max_instances=4,\n    idle_time_before_scale_down=120\n)\n\nml_client.compute.begin_create_or_update(cluster).result()\n```\n\n### List Compute\n\n```python\nfor compute in ml_client.compute.list():\n    print(f\"{compute.name}: {compute.type}\")\n```\n\n## Jobs\n\n### Command Job\n\n```python\nfrom azure.ai.ml import command, Input\n\njob = command(\n    code=\".\u002Fsrc\",\n    command=\"python train.py --data ${{inputs.data}} --lr ${{inputs.learning_rate}}\",\n    inputs={\n        \"data\": Input(type=\"uri_folder\", path=\"azureml:my-dataset:1\"),\n        \"learning_rate\": 0.01\n    },\n    environment=\"AzureML-sklearn-1.0-ubuntu20.04-py38-cpu@latest\",\n    compute=\"cpu-cluster\",\n    display_name=\"training-job\"\n)\n\nreturned_job = ml_client.jobs.create_or_update(job)\nprint(f\"Job URL: {returned_job.studio_url}\")\n```\n\n### Monitor Job\n\n```python\nml_client.jobs.stream(returned_job.name)\n```\n\n## Pipelines\n\n```python\nfrom azure.ai.ml import dsl, Input, Output\nfrom azure.ai.ml.entities import Pipeline\n\n@dsl.pipeline(\n    compute=\"cpu-cluster\",\n    description=\"Training pipeline\"\n)\ndef training_pipeline(data_input):\n    prep_step = prep_component(data=data_input)\n    train_step = train_component(\n        data=prep_step.outputs.output_data,\n        learning_rate=0.01\n    )\n    return {\"model\": train_step.outputs.model}\n\npipeline = training_pipeline(\n    data_input=Input(type=\"uri_folder\", path=\"azureml:my-dataset:1\")\n)\n\npipeline_job = ml_client.jobs.create_or_update(pipeline)\n```\n\n## Environments\n\n### Create Custom Environment\n\n```python\nfrom azure.ai.ml.entities import Environment\n\nenv = Environment(\n    name=\"my-env\",\n    version=\"1\",\n    image=\"mcr.microsoft.com\u002Fazureml\u002Fopenmpi4.1.0-ubuntu20.04\",\n    conda_file=\".\u002Fenvironment.yml\"\n)\n\nml_client.environments.create_or_update(env)\n```\n\n## Datastores\n\n### List Datastores\n\n```python\nfor ds in ml_client.datastores.list():\n    print(f\"{ds.name}: {ds.type}\")\n```\n\n### Get Default Datastore\n\n```python\ndefault_ds = ml_client.datastores.get_default()\nprint(f\"Default: {default_ds.name}\")\n```\n\n## MLClient Operations\n\n| Property | Operations |\n|----------|------------|\n| `workspaces` | create, get, list, delete |\n| `jobs` | create_or_update, get, list, stream, cancel |\n| `models` | create_or_update, get, list, archive |\n| `data` | create_or_update, get, list |\n| `compute` | begin_create_or_update, get, list, delete |\n| `environments` | create_or_update, get, list |\n| `datastores` | create_or_update, get, list, get_default |\n| `components` | create_or_update, get, list |\n\n## Best Practices\n\n1. **Use versioning** for data, models, and environments\n2. **Configure idle scale-down** to reduce compute costs\n3. **Use environments** for reproducible training\n4. **Stream job logs** to monitor progress\n5. **Register models** after successful training jobs\n6. **Use pipelines** for multi-step workflows\n7. **Tag resources** for organization and cost tracking\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,81,862,"2026-05-16 13:05:16",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"30638430-2092-4965-a69b-30f543e89cb7","1.0.0","azure-ai-ml-py.zip",2295,"uploads\u002Fskills\u002Fc91ee933-b953-4ae0-81f5-3f5a61ecf5dc\u002Fazure-ai-ml-py.zip","0d7308505a727f5fb7e39fff0a909da6b355ef7eea4e953ac248465b177f5b66","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":6231}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]