Azure / Azure/custom-script-extension-linux
Set-AzVMExtension settings not working as az vm extension settings
- Dominant language
- Go
- Stars
- 113
- Forks
- 46
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 3
Description
When I am using powershell commands the settings property is not setting up in the extension, but its working with az cli command.
Powershell Commands:
$storageAccountName = "SAName"
$reRunId = [string](New-Guid).Guid
$fileURI = @("https://SAName.blob.core.windows.net/linux/linux.sh", "https://SAName.blob.core.windows.net/linux/file1.conf", "https://SAName.blob.core.windows.net/linux/file2.sh")
$ScriptSettings = @{"fileUris" = $fileURI ; "commandToExecute" = 'bash ./linux.sh'};
$ProtectedSettings = @{"storageAccountName" = $storageAccountName; "storageAccountKey" = $storageAccountKey};
Set-AzVMExtension -ResourceGroupName 'RGName' -Location 'SoutheastAsia' -VMName 'VMName' -Name "CustomScript" -Publisher "Microsoft.Azure.Extensions" -TypeHandlerVersion 2.1 -ExtensionType "CustomScript" -Settings $ScriptSettings -ProtectedSettings $ProtectedSettings -ForceRerun $reRunId
PS Commands Extension output:
Get-AzVMExtension -ResourceGroupName 'rg-name' -VMName 'VMName' | Where-Object Name -EQ 'customScript'
ResourceGroupName : rg-name
VMName : VMName
Name : CustomScript
Location : southeastasia
Etag : {}
Publisher : Microsoft.Azure.Extensions
ExtensionType : CustomScript
TypeHandlerVersion : 2.1
Id : /subscriptions/xxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/rg-name/providers/Microsoft.Compute/virtualMachines/vmname/extensions/CustomScript
PublicSettings :
ProtectedSettings :
ProvisioningState : Succeeded
Statuses :
SubStatuses :
AutoUpgradeMinorVersion : True
ForceUpdateTag :
EnableAutomaticUpgrade :
AZ CLI Commands:
az vm extension set `
--resource-group 'rg-name' `
--vm-name 'vmname' `
--name "customScript" `
--publisher Microsoft.Azure.Extensions.customScript `
--settings (($ScriptSettings | ConvertTo-Json -Compress).Replace("""","\""")) `
--protected-settings (($ProtectedSettings | ConvertTo-Json -Compress).Replace("""","\"""))
AZ CLI Extension output:
Get-AzVMExtension -ResourceGroupName 'rg-name' -VMName 'vmname' | Where-Object Name -EQ 'customScript'
ResourceGroupName : rg-name
VMName : vmname
Name : customScript
Location : southeastasia
Etag : {}
Publisher : Microsoft.Azure.Extensions
ExtensionType : customScript
TypeHandlerVersion : 2.1
Id : /subscriptions/xxxxxxxxxxxxxxxxxxxxx/resourceGroups/rg-name/providers/Microsoft.Compute/virtualMachines/vmname/extensions/customScript
PublicSettings : {
"commandToExecute": "bash ./linux.sh",
"fileUris": [
"https://SAName.blob.core.windows.net/linux/linux.sh",
"https://SAName.blob.core.windows.net/linux/file1.conf",
"https://SAName.blob.core.windows.net/linux/file2.sh"
]
}
ProtectedSettings :
ProvisioningState : Succeeded
Statuses :
SubStatuses :
AutoUpgradeMinorVersion : True
ForceUpdateTag :
EnableAutomaticUpgrade :
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.