diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 7f7da7cea..25906879a 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -166,7 +166,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.setRuntimeParameters(b.stateBag) b.setTemplateParameters(b.stateBag) b.setImageParameters(b.stateBag) - var steps []multistep.Step deploymentName := b.stateBag.Get(constants.ArmDeploymentName).(string) @@ -195,6 +194,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.stateBag.Put(constants.ArmManagedImageSharedGalleryReplicationRegions, b.config.SharedGalleryDestination.SigDestinationReplicationRegions) } + var steps []multistep.Step if b.config.OSType == constants.Target_Linux { steps = []multistep.Step{ NewStepCreateResourceGroup(azureClient, ui), @@ -240,7 +240,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack WinRMConfig: func(multistep.StateBag) (*communicator.WinRMConfig, error) { return &communicator.WinRMConfig{ Username: b.config.UserName, - Password: b.config.tmpAdminPassword, + Password: b.config.Comm.WinRMPassword, }, nil }, }, diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 976dc2c84..18b426e19 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -640,8 +640,13 @@ func setUserNamePassword(c *Config) { if c.Comm.SSHPassword != "" { c.Password = c.Comm.SSHPassword - } else { - c.Password = c.tmpAdminPassword + return + } + + // Configure password settings using Azure generated credentials + c.Password = c.tmpAdminPassword + if c.Comm.WinRMPassword == "" { + c.Comm.WinRMPassword = c.Password } }