-
Notifications
You must be signed in to change notification settings - Fork 39
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 :