首页 > 解决方案 > 在 Azure 管道中使用 Az Ml CLI 部署/更新 Azure ML 模型

问题描述

如果工作区中不存在 azure ml 模型,我正在尝试部署该模型,并且当模型已在注册的工作区中可用时,仅当更新可用时才使用最新版本更新模型,但我不知道这是怎么回事在实践中工作。

Azure 管道将按每周计划运行。

steps:
- task: AzureCLI@2
  displayName: 'Install AML CLI'
  inputs:
    azureSubscription: $(ml_ws_connection)
    scriptLocation: inlineScript
    scriptType: 'bash'
    inlineScript: 'az extension add -n azure-cli-ml'

- task: AzureCLI@2
  displayName: 'Attach folder to workspace'
  inputs:
    azureSubscription: $(ml_ws_connection)
    workingDirectory: $(ml_path)
    scriptLocation: inlineScript
    scriptType: 'bash'
    inlineScript: 'az ml folder attach -w $(ml_ws) -g $(ml_rg)'


# Add potential automated tests

- task: AzureCLI@2
  displayName: 'Create AKS cluster'
  inputs:
    azureSubscription: $(ml_ws_connection)
    workingDirectory: $(ml_path)
    scriptLocation: inlineScript
    scriptType: 'bash'
    inlineScript: 'az ml computetarget create aks --name $(ml_aks_name) --cluster-purpose DevTest'

- task: AzureCLI@2
  displayName: 'Deploy model to AKS '
  inputs:
    azureSubscription: $(ml_ws_connection)
    workingDirectory: $(ml_path)
    scriptLocation: inlineScript
    scriptType: 'bash'
    inlineScript: 'az ml model deploy --name model1_aks --ct $(ml_aks_name) --ic config/inferenceConfig.json -e $(ml_env_name) --ev $(ml_env_version) --dc config/aksDeploymentConfig-aks.json  --overwrite'

- task: AzureCLI@2
  displayName: 'Update model in AKS '
  inputs:
    azureSubscription: $(ml_ws_connection)
    workingDirectory: $(ml_path)
    scriptLocation: inlineScript
    scriptType: 'bash'
    inlineScript: 'az ml service update --name $(deploy_service_name)

标签: azureazure-devopsazure-machine-learning-servicemlops

解决方案


我们可以为自动化模型发布执行 CICD,如此处所述持续部署 Azure 机器学习模型 - Azure 机器学习 | 微软文档

请遵循 CLI 规范的参考资料。这是使用配置更新部署的链接。

Azure CLI的 ml 扩展是 Azure 机器学习用户的改进界面。它使您能够从命令行训练和部署模型,其功能可加速向上和向外扩展数据科学过程,同时跟踪模型生命周期。使用 CLI,您可以在 GPU 计算上运行分布式训练作业,自动扫描超参数以改进您的结果,然后在 AML Studio 用户界面中监控作业以查看所有详细信息,包括重要指标、元数据和工件,如训练模型、检查点和日志。

此外,CLI 经过优化以支持基于 YAML 的作业、端点和资产规范,使用户能够创建、管理和部署具有适当 CI/CD(或 GitOps)最佳实践的模型,以实现端到端MLOps 解决方案

要开始使用 Azure 的 2.0 机器学习 CLI 扩展,请查看此处的链接


推荐阅读