title: Deploy/update Azure ML Model Using Az Ml CLI in Azure pipelines
body: <p>I'm trying to deploy the azure ml model if not exists in the workspace and when the model is already available in the registered workspace then update the model with the latest version only when an update is available, but I don't know how this works in practice.</p>
  <p>The Azure pipelines will run on a weekly schedule.</p>
  <pre><code>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)
  </code></pre>