terraform-provider-azurestack icon indicating copy to clipboard operation
terraform-provider-azurestack copied to clipboard

VM extension - The value of parameter typeHandlerVersion is invalid

Open rzand opened this issue 5 years ago • 8 comments

Hello, I cannot get the azurestack_virtual_machine_extension working on a Windows VM. The az vm extension image list --location someplace -o table command shows Name Publisher Version


CustomScriptExtension Microsoft.Compute 1.9.3 CustomScript Microsoft.Azure.Extensions 2.0.6 CustomScriptForLinux Microsoft.OSTCExtensions 1.5.5

I used

publisher = "Microsoft.Compute" type = "CustomScriptExtension" type_handler_version = "1.9.3"

but keep getting the error: Error: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The value of parameter typeHandlerVersion is invalid." Target="typeHandlerVersion"

Can somebody please advise? Thanks.

rzand avatar Sep 29 '20 17:09 rzand

I solved the above by using type_handler_version = "1.9" instead of type_handler_version = "1.9.3" Regards.

rzand avatar Oct 12 '20 11:10 rzand

Thank you for sharing!!! Bumped into the same error because of version number as well.

syunwei avatar Sep 21 '21 23:09 syunwei

This is still an issue.

torbendury avatar Feb 16 '22 11:02 torbendury

Very interesting behaviour indeed. Bumped into this issue too.

Instead of the below:

publisher = "Microsoft.Azure.Diagnostics"
type = "IaaSDiagnostics"
type_handler_version = "1.20.0.1"

I have to specify it as below:

publisher = "Microsoft.Azure.Diagnostics"
type = "IaaSDiagnostics"
type_handler_version = "1.20"

kiazhi avatar May 06 '22 15:05 kiazhi

Also experiencing this issue right now, setting to 1.9 doesnt fix it for me, i've tried several versions but my CSE still fails on Windows

DeclanKainos avatar Jun 17 '22 12:06 DeclanKainos

For anyone still experiencing this issue, we encountered it today. HashiCorp documentation on this provider is wrong and misleading.

See here

https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows

Look under the Admin Portal for the CustomScriptExtension version you are running. In my case, it is exactly like that link .. 1.10.x

For some reason it only wants the two digit version.

Additionally you need to fill out the virtual_machine_extension information as if you had sent via ARM:

“publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.10",

if you notice, that maps one for one with the terraform provider.

If I ever figure out the PS cmdlet to query the Marketplace Management to find this information then I may post it. Point though it can be found in the GUI and you just need the correct publisher name, type and version.

Once I did that, the problem went away and I was able to run my script.

This part here needs a warning or note to match the publisher and typeVersion for your Azure Stack:

resource "azurestack_virtual_machine_extension" "test" { name = "hostname" location = "West US" resource_group_name = azurestack_resource_group.test.name virtual_machine_name = azurestack_virtual_machine.test.name publisher = "Microsoft.Azure.Extensions" type = "CustomScript" type_handler_version = "2.0"

settings = <<SETTINGS { "commandToExecute": "hostname && uptime" } SETTINGS

tags = { environment = "Production" } }

https://registry.terraform.io/providers/hashicorp/azurestack/latest/docs/resources/virtual_machine_extension.html

This issue can be closed when HashiCorp terraform azurestack provider documentation is updated so not to confuse people. I believe the azurestack documentation person may have copied the information from azurerm. That likely works in azurerm but definitely the publisher is not right for azurestack.

BrianWilkinsFL avatar Oct 07 '23 12:10 BrianWilkinsFL

I encountered the same issue:

publisher            = "Microsoft.Compute"
  type                 = "CustomScriptExtension"
  type_handler_version = "1.9.5"

had to change to

type_handler_version =  "1.9"

before it worked

iyketheintrovert avatar Oct 08 '23 20:10 iyketheintrovert

Still an issue for myself, ended up having to right a function to replace() any values with more than two decimal places. Also automatic_upgrade_enabled has no affect either.

benlavender avatar Jun 10 '24 12:06 benlavender