Working bicep example for Azure ML environments

Mathias Kvist Aarup 1 Reputation point
2022-05-11T11:53:00.557+00:00

Hi

I'm trying to deploy an environment and environment version to Azure ML using Bicep. The documentation doesn't have any examples, and I keep getting an unhelpful error stating:

"The response for resource had empty or invalid content."

Can anyone provide a working example deploying the following two resources:

Microsoft.MachineLearningServices/workspaces/environments@2021-03-01-preview
Microsoft.MachineLearningServices/workspaces/environments/versions@2021-03-01-preview

My config is like this and it can successfully deploy the cluster, but not the environment and version:

param location string = resourceGroup().location

resource amlCluster 'Microsoft.MachineLearningServices/workspaces/computes@2022-01-01-preview' = {
  name: 'workspaceA/cluster'
  location: location
  tags: {
    project: 'projectA'
  }
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    computeLocation: location
    computeType: 'AmlCompute'
    properties: {
      osType: 'Linux'
      vmSize: 'STANDARD_D1'
      scaleSettings: {
        minNodeCount: 0
        maxNodeCount: 2
      }
      subnet: null
    }
  }
}

// Create environment
resource amlEnv 'Microsoft.MachineLearningServices/workspaces/environments@2021-03-01-preview' = {
  name: 'workspaceA/env'
  properties: {
    properties: {}
    tags: {}
  }

}

resource amlEnvVersion 'Microsoft.MachineLearningServices/workspaces/environments/versions@2021-03-01-preview' = {
  name: 'env-version'
  parent: amlEnv
  properties: {
    properties: {}
    isAnonymous: false
    docker: {
        platform: {
            operatingSystemType: 'Linux'
        }
        dockerSpecificationType: 'Image'
        dockerImageUri: 'mcr.microsoft.com/azureml/base:intelmpi2018.3-ubuntu16.04'
    }
    condaFile: 'conda.yml'
  }
}
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,561 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MikeC 66 Reputation points
    2022-06-07T16:10:59.04+00:00

    Check on this - https://medium.com/codex/using-bicep-to-create-workspace-resources-and-get-started-with-azure-machine-learning-bcc57fd4fd09

    Azure create no bicep related, you need to search for external resource

    0 comments No comments

  2. Michal Zindulka 1 Reputation point
    2022-07-02T10:13:41.05+00:00

    Hi, I had the same issue. I could not create a custom environment and then a version as stated in the documentation and even when you export the ARM template from existing resources. Then by the 'try/fail' approach, I found that I don't need to create an 'environments' resource at all, only the 'environments/version' is enough, but need to specify the valid path in the 'name' property.

    param ml_workspace_name string = 'my-workspace'  
    param ml_cust_env_name string = 'MY_CUSTOM_ENV'  
    param ml_cust_env_version string = '1'  
    param ml_cust_env_image string = 'myacr.azurecr.io/my-image:dev'  
      
    resource ml_cust_env 'Microsoft.MachineLearningServices/workspaces/environments/versions@2022-05-01' = {  
      name: '${ml_workspace_name}/${ml_cust_env_name}/${ml_cust_env_version}'  
      properties: {  
        image: ml_cust_env_image  
        osType: 'Linux'  
      }  
    }  
    
    0 comments No comments