Skip to content

Set-AzVMExtension settings not working as az vm extension settings #222

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.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 :

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions