func expandAzureRmVirtualMachineDataDisk(d *schema.ResourceData) ([]compute.DataDisk, error) {
	disks := d.Get("storage_data_disk").([]interface{})
	data_disks := make([]compute.DataDisk, 0, len(disks))
	for _, disk_config := range disks {
		config := disk_config.(map[string]interface{})

		name := config["name"].(string)
		vhd := config["vhd_uri"].(string)
		createOption := config["create_option"].(string)
		lun := int32(config["lun"].(int))
		disk_size := int32(config["disk_size_gb"].(int))

		data_disk := compute.DataDisk{
			Name: &name,
			Vhd: &compute.VirtualHardDisk{
				URI: &vhd,
			},
			Lun:          &lun,
			DiskSizeGB:   &disk_size,
			CreateOption: compute.DiskCreateOptionTypes(createOption),
		}

		data_disks = append(data_disks, data_disk)
	}

	return data_disks, nil
}
func expandAzureRMVirtualMachineScaleSetsStorageProfileOsDisk(d *schema.ResourceData) (*compute.VirtualMachineScaleSetOSDisk, error) {
	osDiskConfigs := d.Get("storage_profile_os_disk").(*schema.Set).List()

	osDiskConfig := osDiskConfigs[0].(map[string]interface{})
	name := osDiskConfig["name"].(string)
	image := osDiskConfig["image"].(string)
	caching := osDiskConfig["caching"].(string)
	osType := osDiskConfig["os_type"].(string)
	createOption := osDiskConfig["create_option"].(string)

	var vhdContainers []string
	containers := osDiskConfig["vhd_containers"].(*schema.Set).List()
	for _, v := range containers {
		str := v.(string)
		vhdContainers = append(vhdContainers, str)
	}

	osDisk := &compute.VirtualMachineScaleSetOSDisk{
		Name:          &name,
		Caching:       compute.CachingTypes(caching),
		OsType:        compute.OperatingSystemTypes(osType),
		CreateOption:  compute.DiskCreateOptionTypes(createOption),
		VhdContainers: &vhdContainers,
	}

	if image != "" {
		osDisk.Image = &compute.VirtualHardDisk{
			URI: &image,
		}
	}

	return osDisk, nil

}
func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk, error) {
	disks := d.Get("storage_os_disk").(*schema.Set).List()

	if len(disks) != 1 {
		return nil, fmt.Errorf("[ERROR] Only 1 OS Disk Can be specified for an Azure RM Virtual Machine")
	}

	disk := disks[0].(map[string]interface{})

	name := disk["name"].(string)
	vhdURI := disk["vhd_uri"].(string)
	createOption := disk["create_option"].(string)

	osDisk := &compute.OSDisk{
		Name: &name,
		Vhd: &compute.VirtualHardDisk{
			URI: &vhdURI,
		},
		CreateOption: compute.DiskCreateOptionTypes(createOption),
	}

	if v := disk["caching"].(string); v != "" {
		osDisk.Caching = compute.CachingTypes(v)
	}

	return osDisk, nil
}
func expandAzureRmVirtualMachineOsDisk(d *schema.ResourceData) (*compute.OSDisk, error) {
	disks := d.Get("storage_os_disk").(*schema.Set).List()

	disk := disks[0].(map[string]interface{})

	name := disk["name"].(string)
	vhdURI := disk["vhd_uri"].(string)
	imageURI := disk["image_uri"].(string)
	createOption := disk["create_option"].(string)

	osDisk := &compute.OSDisk{
		Name: &name,
		Vhd: &compute.VirtualHardDisk{
			URI: &vhdURI,
		},
		CreateOption: compute.DiskCreateOptionTypes(createOption),
	}

	if v := disk["image_uri"].(string); v != "" {
		osDisk.Image = &compute.VirtualHardDisk{
			URI: &imageURI,
		}
	}

	if v := disk["os_type"].(string); v != "" {
		if v == "linux" {
			osDisk.OsType = compute.Linux
		} else if v == "windows" {
			osDisk.OsType = compute.Windows
		} else {
			return nil, fmt.Errorf("[ERROR] os_type must be 'linux' or 'windows'")
		}
	}

	if v := disk["caching"].(string); v != "" {
		osDisk.Caching = compute.CachingTypes(v)
	}

	if v := disk["disk_size_gb"].(int); v != 0 {
		diskSize := int32(v)
		osDisk.DiskSizeGB = &diskSize
	}

	return osDisk, nil
}