I am trying to execute the below locals block on an azure VM using the Custom Script Extension, the issue I keep hitting is it only executes the first line (It creates the folder), what am i missing???
here is the section from the extension
protected_settings = jsonencode({
"commandToExecute" : "powershell -ExecutionPolicy Unrestricted ${local.del_posh}"
})
locals {
del_cmd01 = <<-EOF
New-Item -ItemType Directory -Force -Path ‘C:\_demo\Applications’
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module Az -Force
$destinationPath = ‘C:\_demo\Applications’
ctx = New-AzStorageContext -StorageAccountName '{azurerm_storage_account.saw.name}’ -StorageAccountKey ‘${azurerm_storage_account.saw.primary_access_key}’
blobs = @('{azurerm_storage_blob.hpc2019.name}‘, ‘{azurerm_storage_blob.r-4-1-3.name}', '{azurerm_storage_blob.r-4-2-3.name}’, ‘${azurerm_storage_blob.r-tools-40.name}’)
foreach ($blob in $blobs) {
$blobName = $blob
$blobPath = Join-Path -Path $destinationPath -ChildPath blobName
Get-AzStorageBlobContent -Container '{azurerm_storage_container.cckcompute.name}’ -Blob $blobName -Destination $blobPath -Context $ctx
}
Copy-Item -Path “$destinationPath\HPCPack2019Update2-Full-v7756.zip” -Destination ‘c:\install’ -Force
EOF
del_posh = local.del_cmd01
}