hashicorp / hashicorp/packer-plugin-azure

Uploading large file and directories using SSH communicator to create Azure Windows Image

Open
#288 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
63
Forks
103
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @Zaheerkhan999 in https://github.com/hashicorp/packer/issues/12284 and has been migrated to this repository. The original issue description is below._

---
Hi,

I am creating an image with file folders to be uploaded into the Azure windows image.

What I have done so far. I have created a custom windows image with SSH server installed and running the below packer script to provision a new image from that custom image. Packer is able to create all the required resources at runtime but not able to upload any files to it and terminates with the error "**Context deadline exceeded**".
The same is achievable from winrm but failing with SSH.
Since the files and directories are huge in size so it is taking a lot of time to transfer using winrm that's why I chose SSH communicator to quicky upload the files but its failing.

########################################################################
source "azure-arm" "autogenerated_1" {
azure_tags = {
dept = "Engineering"
task = "Image deployment"
}
build_resource_group_name = "TEST-RG"
client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
communicator = "ssh"
custom_managed_image_name = "SSH-WindowsImage"
custom_managed_image_resource_group_name = "TEST-RG"
managed_image_name = "Windows-image"
managed_image_resource_group_name = "TEST-RG"
os_type = "Windows"
subscription_id = "XXXXXXXXXXXXXXXXXXXXX"
tenant_id = "XXXXXXXXXXXXXXXXXXXXX"
vm_size = "Standard_D2_v2"
ssh_username = "userzktest1"
ssh_password = "PassPktest@123!"
ssh_port = 22
pause_before_connecting = "5m"
ssh_file_transfer_method = "sftp"



}

build {
sources = ["source.azure-arm.autogenerated_1"]


provisioner "file" {
source = "files/bin.zip"
destination = "C:/code/bin.zip"

}

provisioner "powershell" {
inline = ["while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }", "while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }", "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit", "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }"]
}



}
###############################################################################

Any help will be highly appreciated.

Thanks in advance.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided azure-arm configuration with the SSH communicator, SFTP file transfer, and the large files/bin.zip upload. Compare the failing transfer with the stated working WinRM setup and trace where the Context deadline exceeded error occurs; done means the large file or directory upload completes successfully for the Azure Windows image.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.