Search code examples
azureazure-devopsazure-cli

Getting error while downloading the model in Azure Pipeline using azure cli


I have created a CI-CD pipeline for my machine learning model. After my model training is completed , I have registered the model. I am trying to download the model using Azure Cli with the below inline command :

az ml model download -g $(azureml.resourceGroup) -w $(azureml.workspaceName) -i $(jq -r .modelld metadata/model.json) -t ./models --overwrite 

But I am getting error as below :

/opt/hostedtoolcache/Python/3.6.15/x64/lib/python3.6/site-packages/azureml/_cli/cli_command.py:11: FutureWarning: azureml.core: AzureML support for Python 3.6 is deprecated and will be dropped in an upcoming release. At that point, existing Python 3.6 workflows that use AzureML will continue to work without modification, but Python 3.6 users will no longer get access to the latest AzureML features and bugfixes. We recommend that you upgrade to Python 3.7 or newer. To disable SDK V1 deprecation warning set the environment variable AZUREML_DEPRECATE_WARNING to 'False'
  from azureml.core import get_run
ERROR: argument --model-id/-i: expected one argument

As I am very much new to Azure Devops I could not able to identify the issue here. How to solve this issue?


Solution

  • I tried below code to download the az ml model with model ID, You can find the model id which is the name & version of your modelname:versionumber modelml:1 by visiting your Azure ML workspace Model like below:-

    enter image description here

    My Azure Devops CLI Task:-

    YAML Script:-

    - task: AzureCLI@2
    
    inputs:
    
    azureSubscription: '<subscription>'
    
    scriptType: 'bash'
    
    scriptLocation: 'inlineScript'
    
    inlineScript: |
    
    az extension add -n azure-cli-ml
    
    az ml model download --model-id modelml:1 --target-dir <path-where-you-want-to-download-the-model> --resource-group siliconrg12 --workspace-name siliconmlws
    

    I have referred this document for az ml model download command.

    Output:-

    enter image description here

    My Azure CLI code locally:-

    az ml model download --model-id modelml:1 --target-dir C:\ML --resource-group siliconrg12 --workspace-name siliconmlws
    

    Output:-

    enter image description here