I'm attempting to get a PS script working to upload .NET 5 apps to IIS. Using an approach by piping ZIP file content directly to the server failed because the ZIP file is too large. I'm attempting to use BITS, but I'm running
into problems, especially with a connection error and an invalid CA error (because I'm using a self-signed cert). I've tried two approaches with an Azure VM (WS 2012 R2) with the BITS features installed (including the IIS Extension and compact server):
$result = Invoke-WsmanAction `
-Action CreateJob `
ResourceUri wmi/root/microsoft/bits/BitsClientJob `
ValueSet @{ `
DisplayName="CreateJob"; `
RemoteUrl="https://xxxxx.cloudapp.net/deployment/output.zip"; `
LocalFile="$env:USERPROFILE\AppData\Local\Temp\PublishTemp\output.zip"; `
Type=1; `
} `
-Credential $mycreds `
-ComputerName $cloudService `
-Port 50000 `
-UseSSL `
-SessionOption (New-WSManSessionOption -SkipCACheck)
[where $cloudService = xxxxx.cloudapp.net; $mycreds are known good (the server admin account is used), because the PS session is started with them; 50000 maps to 5986 in Azure; 5986 was opened by the BITS installer on the VM and Remote Address on the port is set to "Any"]
It doesn't choke on the fact that I'm using a self-signed certificate, but it throws with an exception stating that ...
"The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol."
I've changed/removed/added the parameters to every possible combination I can think of.
The port endpoint is open in Azure, allowed in the firewall, configured in IIS, with all the BITS stuff on the server and the virtual directory configured with the IIS BITS extension. I am a bit confused about permissions on that folder, deployment, that I setup for the vdir (techdocs are very difficult to comprehend on exactly what permissions settings to apply to each group/user). When I manually add an output.zip file to the vdir and hit the address https://xxxxx.cloudapp.net:50000/deployment/output.zip, I do get the file. When I run the PS script for an upload to that vdir, the Event Log only shows a connection attempt to start the job, followed by a second entry immediately showing that the CreateJob was cancelled (for no apparent reason).
If I try using this ...
$Job = Start-BitsTransfer `
-Source $env:USERPROFILE\AppData\Local\Temp\PublishTemp\output.zip `
-Destination https://xxxxx.cloudapp.net:50000/deployment/output.zip `
-TransferType Upload `
-DisplayName MyJob `
-Credential $mycreds `
-Priority High
... it fails with ...
"The certificate authority is invalid or incorrect"
... no matter if the cert is in the Trusted Root or not and no matter if it's installed on the local machine or not. There is apparently no switch for telling the cmdlet to ignore the CA.
After about 12 hours of trying to get BITS to work for these large file uploads to work with PS, I'm about to abandon it entirely and try something else (e.g., FTP).
Does anyone have tips ... esp. on the first approach, where it doesn't seem to choke on the CA pr