Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
durgaprasad9 opened this issue Jul 10, 2024 · 0 comments
Open

Comments

@durgaprasad9
Copy link

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 :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant