Invoke-WebRequest
is not working in Azure.
I have tested the same code in Powershell ISE and it works.
Here is the error:
4/8/2015 9:24:14 AM, Error: Microsoft.PowerShell.Utility\Write-Error : aa00-csmo-t2 - Could not download https://nage1.blob.core.w
indows.net/application/applicationcertificates.7z?sv=2014-02-14&sr=c&sig=ke1lxWQM%3D&se=2016-04-07T06%3A04%3A49Z&sp=r -
At Install-Certificates:168 char:168
+
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId :
Microsoft.PowerShell.Commands.WriteErrorException,Microsoft.PowerShell.Commands.WriteErrorCommand
Here is the code I was using in Powershell ISE which works:
workflow test
{
$ApplicationCertsBlobUrl = 'https://nage1.blob.core.w
indows.net/application/applicationcertificates.7z?sv=2014-02-14&sr=c&sig=ke1lxWQM%3D&se=2016-04-07T06%3A04%3A49Z&sp=r'
$applicationCertsZipFileSource = 'C:\Temp\test.7z'
Invoke-WebRequest $ApplicationCertsBlobUrl -OutFile $applicationCertsZipFileSource
}
I have also tried:
InlineScript
{
$client = New-Object System.Net.WebClient
$client.DownloadFile($using:ApplicationCertsBlobUrl, $using:applicationCertsZipFileSource)
}
However I get this Exception:
4/8/2015 9:40:14 AM, Error: Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At Install-Certificates:164 char:164
+
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
I had to wrap Invoke-WebRequest
in an InlineScript
.