Search code examples
azuremachine-learningazure-resource-managerazure-bicep

Azure machine learning compute bicep template naming error


I have a file called machine-learning.bicep file which contains both resources machine learning workspace and compute(I want to keep both resources together). Getting the following naming error for the compute resource 'incorrect segment lengths. A nested resource type must have identical number of segments as its resource name. A root resource type must have segment length one greater than its resource name'. I also removed cluster in compute name to match segment length but still getting error

resource machineLearning 'Microsoft.MachineLearningServices/workspaces@2022-01-01-preview' = {
  name: 'mlw-${project}-${env}'
  location: loc
  tags: tags
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    // dependent resources
    applicationInsights: appInsights.id
    containerRegistry: containerRegistry.id
    keyVault: keyVaultId
    storageAccount: storage.id
  }
}

resource amlci 'Microsoft.MachineLearningServices/workspaces/computes@2020-09-01-preview' = {
  name: 'mlw-${project}-${env}-cluster'
  location: loc
  properties: {
    computeType: 'AmlCompute'
    properties: {
      vmSize: 'Standard_DS3_v2'
      subnet: json('null')
      osType: 'Linux'
      scaleSettings: {
        maxNodeCount: 5
        minNodeCount: 0
      }
    }
  }
}

Solution

  • Here, you are missing the parent/child relationship between the ML workspace and the compute resources.

    If you add the parent property on the compute resource it should work:

    resource amlci 'Microsoft.MachineLearningServices/workspaces/computes@2020-09-01-preview' = {
      name: 'mlw-${project}-${env}-cluster'
      parent: machineLearning
      ...
    }