I’m trying to copy a SQL Express installer (exe) which is 446MB to my hyper-v machine via the http_directory function of packer. I can confirm the correct environment variables are referencing the created http server:
hyperv-iso: PACKER_HTTP_ADDR 192.168.0.24:8949
Here is my powershell script which executes as a provisioner:
{
"scripts": [
"./scripts/storeservices/copy_sql_exe.ps1"
],
"type": "powershell"
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
[string] $isoFile = "SQLEXPR_x64_ENU.exe"
[string] $source = "http://$ENV:PACKER_HTTP_ADDR/$isoFile"
[string] $destPath = "C:\Windows\Temp\$isoFile"
Get-Item Env:PACKER_HTTP_ADDR
Write-Host "Attempting to copy from....."
$response = try {
(Invoke-WebRequest -Uri $source -OutFile $destPath -ErrorAction Stop).BaseResponse
} catch [System.Net.WebException] {
Write-Host "Completed Copy from HTTP"
Write-Host "An exception was caught: $($_.Exception.Message)"
$_.Exception.Response
}
My script returns the error: ‘the remote server returned an error (404 not found)’.
My http_directory is set up off the root path that packer executes from:
"builders": [
{
"boot_wait": "6m",
"output_directory":"./output",
"communicator": "winrm",
"http_directory":"./scripts/storeservices/",