From dd04108ac88caf96a02a3813a432f2c99fa9329f Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Thu, 19 Mar 2020 12:11:34 +0530 Subject: [PATCH 1/6] Fix :: allow Managed data disks to be used with azure shared image gallery image Sources --- builder/azure/arm/template_factory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/azure/arm/template_factory.go b/builder/azure/arm/template_factory.go index 0d5bc47f3..85d489b49 100644 --- a/builder/azure/arm/template_factory.go +++ b/builder/azure/arm/template_factory.go @@ -95,7 +95,7 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error) } if len(config.AdditionalDiskSize) > 0 { - isManaged := config.CustomManagedImageName != "" || (config.ManagedImageName != "" && config.ImagePublisher != "") + isManaged := config.CustomManagedImageName != "" || (config.ManagedImageName != "" && config.ImagePublisher != "") || config.SharedGallery.Subscription != "" builder.SetAdditionalDisks(config.AdditionalDiskSize, isManaged, config.diskCachingType) } From d82475566a2da22414a60c0b44258e02bce1a87b Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Thu, 2 Apr 2020 21:28:38 +0530 Subject: [PATCH 2/6] change datadisk names -- WIP --- builder/azure/arm/config.go | 2 ++ builder/azure/arm/template_factory.go | 3 ++- builder/azure/arm/tempname.go | 2 ++ builder/azure/common/template/template_builder.go | 6 +++--- builder/azure/common/template/template_builder_test.go | 4 ++-- builder/azure/common/template/template_parameters.go | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index d87ff3426..3f8a88e43 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -392,6 +392,7 @@ type Config struct { tmpDeploymentName string tmpKeyVaultName string tmpOSDiskName string + tmpDataDiskName string tmpSubnetName string tmpVirtualNetworkName string tmpNsgName string @@ -645,6 +646,7 @@ func setRuntimeValues(c *Config) { c.tmpNicName = tempName.NicName c.tmpPublicIPAddressName = tempName.PublicIPAddressName c.tmpOSDiskName = tempName.OSDiskName + c.tmpDataDiskName = tempName.DataDiskname c.tmpSubnetName = tempName.SubnetName c.tmpVirtualNetworkName = tempName.VirtualNetworkName c.tmpNsgName = tempName.NsgName diff --git a/builder/azure/arm/template_factory.go b/builder/azure/arm/template_factory.go index 85d489b49..fbd3fe8e9 100644 --- a/builder/azure/arm/template_factory.go +++ b/builder/azure/arm/template_factory.go @@ -37,6 +37,7 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error) DnsNameForPublicIP: &template.TemplateParameter{Value: config.tmpComputeName}, NicName: &template.TemplateParameter{Value: config.tmpNicName}, OSDiskName: &template.TemplateParameter{Value: config.tmpOSDiskName}, + DataDiskName: &template.TemplateParameter{Value: config.tmpDataDiskName}, PublicIPAddressName: &template.TemplateParameter{Value: config.tmpPublicIPAddressName}, SubnetName: &template.TemplateParameter{Value: config.tmpSubnetName}, StorageAccountBlobEndpoint: &template.TemplateParameter{Value: config.storageAccountBlobEndpoint}, @@ -96,7 +97,7 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error) if len(config.AdditionalDiskSize) > 0 { isManaged := config.CustomManagedImageName != "" || (config.ManagedImageName != "" && config.ImagePublisher != "") || config.SharedGallery.Subscription != "" - builder.SetAdditionalDisks(config.AdditionalDiskSize, isManaged, config.diskCachingType) + builder.SetAdditionalDisks(config.AdditionalDiskSize, config.tmpDataDiskName, isManaged, config.diskCachingType) } if config.customData != "" { diff --git a/builder/azure/arm/tempname.go b/builder/azure/arm/tempname.go index 45fb97e63..1471e44ac 100644 --- a/builder/azure/arm/tempname.go +++ b/builder/azure/arm/tempname.go @@ -15,6 +15,7 @@ type TempName struct { KeyVaultName string ResourceGroupName string OSDiskName string + DataDiskname string NicName string SubnetName string PublicIPAddressName string @@ -30,6 +31,7 @@ func NewTempName() *TempName { tempName.DeploymentName = fmt.Sprintf("pkrdp%s", suffix) tempName.KeyVaultName = fmt.Sprintf("pkrkv%s", suffix) tempName.OSDiskName = fmt.Sprintf("pkros%s", suffix) + tempName.DataDiskname = fmt.Sprintf("pkrdd%s", suffix) tempName.NicName = fmt.Sprintf("pkrni%s", suffix) tempName.PublicIPAddressName = fmt.Sprintf("pkrip%s", suffix) tempName.SubnetName = fmt.Sprintf("pkrsn%s", suffix) diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index 6d276c010..0fad25bd5 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -231,7 +231,7 @@ func (s *TemplateBuilder) SetOSDiskSizeGB(diskSizeGB int32) error { return nil } -func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool, cachingType compute.CachingTypes) error { +func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, dataDiskname string, isManaged bool, cachingType compute.CachingTypes) error { resource, err := s.getResourceByType(resourceVirtualMachine) if err != nil { return err @@ -243,7 +243,7 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool, for i, additionalSize := range diskSizeGB { dataDisks[i].DiskSizeGB = to.Int32Ptr(additionalSize) dataDisks[i].Lun = to.IntPtr(i) - dataDisks[i].Name = to.StringPtr(fmt.Sprintf("datadisk-%d", i+1)) + dataDisks[i].Name = to.StringPtr(fmt.Sprintf("%s-%d", dataDiskname, i+1)) dataDisks[i].CreateOption = "Empty" dataDisks[i].Caching = cachingType if isManaged { @@ -251,7 +251,7 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, isManaged bool, dataDisks[i].ManagedDisk = profile.OsDisk.ManagedDisk } else { dataDisks[i].Vhd = &compute.VirtualHardDisk{ - URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '%d','.vhd')]", i+1)), + URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/%s-', '%d','.vhd')]", dataDiskname, i+1)), } dataDisks[i].ManagedDisk = nil } diff --git a/builder/azure/common/template/template_builder_test.go b/builder/azure/common/template/template_builder_test.go index b39af103f..39e51fd53 100644 --- a/builder/azure/common/template/template_builder_test.go +++ b/builder/azure/common/template/template_builder_test.go @@ -138,7 +138,7 @@ func TestBuildWindows01(t *testing.T) { t.Fatal(err) } - err = testSubject.SetAdditionalDisks([]int32{32, 64}, true, compute.CachingTypesReadWrite) + err = testSubject.SetAdditionalDisks([]int32{32, 64}, "datadisk", true, compute.CachingTypesReadWrite) if err != nil { t.Fatal(err) } @@ -166,7 +166,7 @@ func TestBuildWindows02(t *testing.T) { t.Fatal(err) } - err = testSubject.SetAdditionalDisks([]int32{32, 64}, false, compute.CachingTypesReadWrite) + err = testSubject.SetAdditionalDisks([]int32{32, 64}, "datadisk", false, compute.CachingTypesReadWrite) if err != nil { t.Fatal(err) } diff --git a/builder/azure/common/template/template_parameters.go b/builder/azure/common/template/template_parameters.go index 6900deb82..262c85e56 100644 --- a/builder/azure/common/template/template_parameters.go +++ b/builder/azure/common/template/template_parameters.go @@ -27,6 +27,7 @@ type TemplateParameters struct { ObjectId *TemplateParameter `json:"objectId,omitempty"` NicName *TemplateParameter `json:"nicName,omitempty"` OSDiskName *TemplateParameter `json:"osDiskName,omitempty"` + DataDiskName *TemplateParameter `json:"dataDiskName,omitempty"` PublicIPAddressName *TemplateParameter `json:"publicIPAddressName,omitempty"` StorageAccountBlobEndpoint *TemplateParameter `json:"storageAccountBlobEndpoint,omitempty"` SubnetName *TemplateParameter `json:"subnetName,omitempty"` From 0589f57d4d85ef28054d47049c346e53c1698205 Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Sun, 5 Apr 2020 01:16:24 +0530 Subject: [PATCH 3/6] Update tests for datadisk name change --- ...template_factory_test.TestPlanInfo01.approved.json | 3 +++ ...template_factory_test.TestPlanInfo02.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment03.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment04.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment05.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment06.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment07.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment08.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment09.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment10.approved.json | 3 +++ ..._test.TestVirtualMachineDeployment11.approved.json | 7 +++++-- ..._test.TestVirtualMachineDeployment12.approved.json | 5 ++++- ..._test.TestVirtualMachineDeployment13.approved.json | 3 +++ builder/azure/common/template/template_builder.go | 10 +++++++--- ...mplate_builder_test.TestBuildLinux00.approved.json | 3 +++ ...mplate_builder_test.TestBuildLinux01.approved.json | 3 +++ ...mplate_builder_test.TestBuildLinux02.approved.json | 3 +++ ...late_builder_test.TestBuildWindows00.approved.json | 3 +++ ...late_builder_test.TestBuildWindows01.approved.json | 7 +++++-- ...late_builder_test.TestBuildWindows02.approved.json | 11 +++++++---- ...lder_test.TestNetworkSecurityGroup00.approved.json | 3 +++ ...uilder_test.TestSharedImageGallery00.approved.json | 3 +++ 22 files changed, 79 insertions(+), 12 deletions(-) diff --git a/builder/azure/arm/template_factory_test.TestPlanInfo01.approved.json b/builder/azure/arm/template_factory_test.TestPlanInfo01.approved.json index 30ede3ae4..eb841ab4d 100644 --- a/builder/azure/arm/template_factory_test.TestPlanInfo01.approved.json +++ b/builder/azure/arm/template_factory_test.TestPlanInfo01.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestPlanInfo02.approved.json b/builder/azure/arm/template_factory_test.TestPlanInfo02.approved.json index 657af585d..9a9f6e523 100644 --- a/builder/azure/arm/template_factory_test.TestPlanInfo02.approved.json +++ b/builder/azure/arm/template_factory_test.TestPlanInfo02.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json index cda8c56dc..1f0e43265 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json index 8c922bfa5..24d96726a 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json index 9e66583fb..f4cc6f3ab 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment06.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment06.approved.json index ce8b43ed8..0f29794ce 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment06.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment06.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment07.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment07.approved.json index 66cf47288..191719eec 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment07.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment07.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment08.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment08.approved.json index cdabe3c93..f411e5a6e 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment08.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment08.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment09.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment09.approved.json index 5af5b01bc..b9a8c8d79 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment09.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment09.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment10.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment10.approved.json index a9c3d267c..c330259ae 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment10.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment10.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json index 5ac3905c0..1d777f432 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, @@ -144,9 +147,9 @@ "createOption": "Empty", "diskSizeGB": 32, "lun": 0, - "name": "datadisk-1", + "name": "[concat(parameters('dataDiskName'),'-1'", "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '1','.vhd')]" + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]" } } ], diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json index 4339b1864..ba14d9fd6 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, @@ -147,7 +150,7 @@ "managedDisk": { "storageAccountType": "Standard_LRS" }, - "name": "datadisk-1" + "name": "[concat(parameters('dataDiskName'),'-1'" } ], "imageReference": { diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment13.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment13.approved.json index 9127c3bac..66d3689c5 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment13.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment13.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index 0fad25bd5..10cfc785a 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -243,7 +243,8 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, dataDiskname st for i, additionalSize := range diskSizeGB { dataDisks[i].DiskSizeGB = to.Int32Ptr(additionalSize) dataDisks[i].Lun = to.IntPtr(i) - dataDisks[i].Name = to.StringPtr(fmt.Sprintf("%s-%d", dataDiskname, i+1)) + // dataDisks[i].Name = to.StringPtr(fmt.Sprintf("%s-%d", dataDiskname, i+1)) + dataDisks[i].Name = to.StringPtr(fmt.Sprintf("[concat(parameters('dataDiskName'),'-%d'", i+1)) dataDisks[i].CreateOption = "Empty" dataDisks[i].Caching = cachingType if isManaged { @@ -251,7 +252,7 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, dataDiskname st dataDisks[i].ManagedDisk = profile.OsDisk.ManagedDisk } else { dataDisks[i].Vhd = &compute.VirtualHardDisk{ - URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/%s-', '%d','.vhd')]", dataDiskname, i+1)), + URI: to.StringPtr(fmt.Sprintf("[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-%d','.vhd')]", i+1)), } dataDisks[i].ManagedDisk = nil } @@ -581,7 +582,10 @@ const BasicTemplate = `{ }, "vmName": { "type": "string" - } + }, + "dataDiskName": { + "type": "string" + } }, "variables": { "addressPrefix": "10.0.0.0/16", diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json index 4ba861566..de63373bb 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json index 5e5b2ea05..981354c91 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json index b3a2e1e73..f7f3bed74 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json index 797081807..1c29ee885 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json index a7230706d..3929a8650 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, @@ -161,7 +164,7 @@ "managedDisk": { "storageAccountType": "Premium_LRS" }, - "name": "datadisk-1" + "name": "[concat(parameters('dataDiskName'),'-1'" }, { "caching": "ReadWrite", @@ -171,7 +174,7 @@ "managedDisk": { "storageAccountType": "Premium_LRS" }, - "name": "datadisk-2" + "name": "[concat(parameters('dataDiskName'),'-2'" } ], "imageReference": { diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json index ad8d94bfb..1b39bdf23 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, @@ -158,9 +161,9 @@ "createOption": "Empty", "diskSizeGB": 32, "lun": 0, - "name": "datadisk-1", + "name": "[concat(parameters('dataDiskName'),'-1'", "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '1','.vhd')]" + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]" } }, { @@ -168,9 +171,9 @@ "createOption": "Empty", "diskSizeGB": 64, "lun": 1, - "name": "datadisk-2", + "name": "[concat(parameters('dataDiskName'),'-2'", "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/datadisk-', '2','.vhd')]" + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-2','.vhd')]" } } ], diff --git a/builder/azure/common/template/template_builder_test.TestNetworkSecurityGroup00.approved.json b/builder/azure/common/template/template_builder_test.TestNetworkSecurityGroup00.approved.json index b318164a3..7415524d7 100644 --- a/builder/azure/common/template/template_builder_test.TestNetworkSecurityGroup00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestNetworkSecurityGroup00.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, diff --git a/builder/azure/common/template/template_builder_test.TestSharedImageGallery00.approved.json b/builder/azure/common/template/template_builder_test.TestSharedImageGallery00.approved.json index 49f2a72a4..4c83d090d 100644 --- a/builder/azure/common/template/template_builder_test.TestSharedImageGallery00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestSharedImageGallery00.approved.json @@ -8,6 +8,9 @@ "adminUsername": { "type": "string" }, + "dataDiskName": { + "type": "string" + }, "dnsNameForPublicIP": { "type": "string" }, From 1314d69b5140e445528921d88e7692b3dd87b9d7 Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Mon, 6 Apr 2020 11:40:05 +0530 Subject: [PATCH 4/6] fix typo (add missing ')]' ) --- ...te_factory_test.TestVirtualMachineDeployment11.approved.json | 2 +- ...te_factory_test.TestVirtualMachineDeployment12.approved.json | 2 +- builder/azure/common/template/template_builder.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json index 1d777f432..15b0ced92 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment11.approved.json @@ -147,7 +147,7 @@ "createOption": "Empty", "diskSizeGB": 32, "lun": 0, - "name": "[concat(parameters('dataDiskName'),'-1'", + "name": "[concat(parameters('dataDiskName'),'-1')]", "vhd": { "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]" } diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json index ba14d9fd6..77c10f0af 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment12.approved.json @@ -150,7 +150,7 @@ "managedDisk": { "storageAccountType": "Standard_LRS" }, - "name": "[concat(parameters('dataDiskName'),'-1'" + "name": "[concat(parameters('dataDiskName'),'-1')]" } ], "imageReference": { diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index 10cfc785a..651f7c00a 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -244,7 +244,7 @@ func (s *TemplateBuilder) SetAdditionalDisks(diskSizeGB []int32, dataDiskname st dataDisks[i].DiskSizeGB = to.Int32Ptr(additionalSize) dataDisks[i].Lun = to.IntPtr(i) // dataDisks[i].Name = to.StringPtr(fmt.Sprintf("%s-%d", dataDiskname, i+1)) - dataDisks[i].Name = to.StringPtr(fmt.Sprintf("[concat(parameters('dataDiskName'),'-%d'", i+1)) + dataDisks[i].Name = to.StringPtr(fmt.Sprintf("[concat(parameters('dataDiskName'),'-%d')]", i+1)) dataDisks[i].CreateOption = "Empty" dataDisks[i].Caching = cachingType if isManaged { From 1009e8c983002b5f54cde2a01f918f7918b44e7e Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Mon, 6 Apr 2020 21:50:05 +0530 Subject: [PATCH 5/6] fix more typos --- .../template_builder_test.TestBuildWindows01.approved.json | 2 +- .../template_builder_test.TestBuildWindows02.approved.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json index 3929a8650..e3139a5ef 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json @@ -164,7 +164,7 @@ "managedDisk": { "storageAccountType": "Premium_LRS" }, - "name": "[concat(parameters('dataDiskName'),'-1'" + "name": "[concat(parameters('dataDiskName'),'-1')]" }, { "caching": "ReadWrite", diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json index 1b39bdf23..cbbd5cca9 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json @@ -161,7 +161,7 @@ "createOption": "Empty", "diskSizeGB": 32, "lun": 0, - "name": "[concat(parameters('dataDiskName'),'-1'", + "name": "[concat(parameters('dataDiskName'),'-1')]", "vhd": { "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-1','.vhd')]" } From 90a0c5ec491d1907d7101f4f5cb7fdea0aa9eb17 Mon Sep 17 00:00:00 2001 From: Vijay Rajah Date: Mon, 6 Apr 2020 22:02:43 +0530 Subject: [PATCH 6/6] fix more typos ( ')]' ) --- .../template_builder_test.TestBuildWindows01.approved.json | 2 +- .../template_builder_test.TestBuildWindows02.approved.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json index e3139a5ef..9c094ef04 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows01.approved.json @@ -174,7 +174,7 @@ "managedDisk": { "storageAccountType": "Premium_LRS" }, - "name": "[concat(parameters('dataDiskName'),'-2'" + "name": "[concat(parameters('dataDiskName'),'-2')]" } ], "imageReference": { diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json index cbbd5cca9..06f554cda 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows02.approved.json @@ -171,7 +171,7 @@ "createOption": "Empty", "diskSizeGB": 64, "lun": 1, - "name": "[concat(parameters('dataDiskName'),'-2'", + "name": "[concat(parameters('dataDiskName'),'-2')]", "vhd": { "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),parameters('dataDiskName'), '-2','.vhd')]" }