0

I am using Terraform to create Azure VMs, but since those don't have much functionality installed, I was investigating on other Azure resources. I found the Azure Data Science VM is the one that covers most of my requirements, so I was wondering if there is a way to create those with Terraform. I can't see it in the documentation, but maybe there is a workaround.

Any orientation on this would be great!

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
zapatilla
  • 1,711
  • 3
  • 22
  • 38

3 Answers3

3

Assumption

Azure Resource Model.

Steps

There will be several steps to this process. You'll firstly need to retrieve a platform image.

data "azurerm_platform_image" "test" {
   location  = "West Europe"
   publisher = "Microsoft"
   offer     = "xx"
   sku       = "xx"
}

Before you can fully populate this however, you will need to retrieve the SKU and Offer. Annoyingly, this isn't readily available on the internet and requires an API call or Powershell fun.

This link will help you achieve this.

Once you've got the above terraform populated, you can then utilise this to create a virtual machine.

resource "azurerm_virtual_machine" "test" {
    name                  = "acctvm"
    location              = "West US 2"
    resource_group_name   = "${azurerm_resource_group.test.name}"
    network_interface_ids = ["${azurerm_network_interface.test.id}"]
    vm_size               = "Standard_DS1_v2"

storage_image_reference {
    id = "${data.azurerm_platform_image.test.id}"
}

storage_os_disk {
    name              = "myosdisk1"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
}

# Optional data disks
storage_data_disk {
    name              = "datadisk_new"
    managed_disk_type = "Standard_LRS"
    create_option     = "Empty"
    lun               = 0
    disk_size_gb      = "1023"
}

storage_data_disk {
    name            = "${azurerm_managed_disk.test.name}"
    managed_disk_id = "${azurerm_managed_disk.test.id}"
    create_option   = "Attach"
    lun             = 1
    disk_size_gb    = "${azurerm_managed_disk.test.disk_size_gb}"
}

os_profile {
    computer_name  = "hostname"
    admin_username = "testadmin"
    admin_password = "Password1234!"
}

os_profile_linux_config {
    disable_password_authentication = false
}

tags {
    environment = "staging"
}
}
Nathan Smith
  • 8,271
  • 3
  • 27
  • 44
1

Follow steps here. To fill the terraform "storage_image_reference" part you can use the Azure CLI to get the information. So for example:

az vm image list --offer linux-data-science-vm --all --output table

Or

az vm image list --offer windows-data-science-vm --all --output table
Lol
  • 940
  • 8
  • 6
0

Here is the list of SKUs and Offers for the Azure Data Science VM.

Windows Server 2016 edition: offer=windows-data-science-vm sku=windows2016

Ubuntu edition: offer=linux-data-science-vm-ubuntu sku=linuxdsvmubuntu

Windows Server 2012 edition: offer=standard-data-science-vm sku=standard-data-science-vm

CentOS edition: offer=linux-data-science-vm sku=linuxdsvm

Publisher for all these is microsoft-ads

Gopi - MSFT
  • 154
  • 6