Krishnan Sriram
Krishnan Sriram

Reputation: 5449

Create Managed VM compute for Azure Machine learning workspace

Can someone tell me what's the best way to create a managed VM compute instance for Azure ML with terraform and have custom startup scripts. My enterprise requires me to install a few agents as a part of compute and "azurerm_machine_learning_compute_instance" terraform resource does not seem to have a way to do it? Has anyone tried any alternative methods? Or am I missing anything. This is the resource block I have and may be there's a better way to do it?

resource "azurerm_machine_learning_compute_instance" "compute_instance" {
  location                      = var.location
  name                          = "some_name_vm_compute"
  machine_learning_workspace_id = azurerm_machine_learning_workspace.this.id
  virtual_machine_size          = var.vm_size
  subnet_resource_id            = data.azurerm_subnet.compute_subnet.id
  authorization_type            = var.authorization_type
  node_public_ip_enabled        = false
  #TODO: validate assign_to_user for compute_instance and not to any other blocks
  assign_to_user {
    object_id = data.azuread_user.user.object_id
    tenant_id = data.azuread_client_config.current.tenant_id
  }
}

As you see, I cannot add any startup script to this block. I don't want to use null_resource either. I'd appreciate your thoughts?

Should I use VM extensions? Are there any limitations to using it or something more I should be aware off?

Upvotes: 1

Views: 67

Answers (1)

Vinay B
Vinay B

Reputation: 2261

Create Managed VM compute for Azure Machine learning workspace

As per the requirement to create a managed VM compute instance for Azure ML with terraform and have custom startup scripts not supporting by terraform directly due to limitations being a third party provider.

Azure Machine Learning compute instances do not support the same extension mechanism as Azure VMs

I was sharing this info keeping in mind that you're not ready use null resource in your configuration.

With this doing the entire setup in the same configuration was not possible.

You can try this alternative instead using the refer documentation where it suggested methods using SDK, Python or CLI. These steps need to be followed separate from the configuration.

The direct VM extensions are not supported for Azure Machine Learning compute instances, you can achieve similar functionality using custom initialization scripts, the Azure Machine Learning SDK, or the Azure CLI.

Refer doc:

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-managed-network-compute?view=azureml-api-2&tabs=azure-cli

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-customize-compute-instance?view=azureml-api-2

https://github.com/MicrosoftDocs/azure-ai-docs/blob/main/articles/machine-learning/how-to-customize-compute-instance.md

Upvotes: 0

Related Questions