Reputation: 61
I've setup a deployment group successfully via Azure Pipelines and have deployed my Api successfully as well. My homework says that I have to prove that the Api was deployed successfully so I thought that I should run this via IIS. However, a 502.5 error is being thrown and I find out that a server hosting bundle is needed. How do you automate this via Azure PIpelines? I found an Invoke-Webrequest script that does this but it only installs 1.0.0...
Upvotes: 6
Views: 2441
Reputation: 1503
if you are looking to download this directly from MS instead you can use this script:
$ErrorActionPreference="Stop";
If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole( [Security.Principal.WindowsBuiltInRole] “Administrator”)){
throw "Run command in Administrator PowerShell Prompt"
};If($PSVersionTable.PSVersion -lt (New-Object System.Version("3.0"))){ throw "The minimum version of Windows PowerShell that is required by the script (3.0) does not match the currently running version of Windows PowerShell." };
$tempDir = [System.IO.Path]::GetTempPath()
$downloadPath="$tempdir\netCoreHostingBundle.exe";
$DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy;
$securityProtocol=@();
$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol;
$securityProtocol+=[Net.SecurityProtocolType]::Tls12;
[Net.ServicePointManager]::SecurityProtocol=$securityProtocol;
$WebClient=New-Object Net.WebClient;
$Uri='https://download.visualstudio.microsoft.com/download/pr/9b9f4a6e-aef8-41e0-90db-bae1b0cf4e34/4ab93354cdff8991d91a9f40d022d450/dotnet-hosting-3.1.6-win.exe';
if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){$WebClient.Proxy= New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True);};
$WebClient.DownloadFile($Uri, $downloadPath);
$args = New-Object -TypeName System.Collections.Generic.List[System.String]
$args.Add("/quiet")
$args.Add("/norestart")
Start-Process -FilePath $downloadPath -ArgumentList $args -NoNewWindow -Wait -PassThru -WorkingDirectory $tempDir
Upvotes: 1
Reputation: 1583
I'm not sure if there is a built in way to do this, but in our project we've done it by including the DotNetCore.2.0.7-WindowsHosting.exe
installer in our build artifacts and simply executing the installer with a Powershell step at the beginning of the release process.
You'll want to use the /quiet
and /norestart
flags:
$Path = "path to your installer exe in artifacts"
$args = New-Object -TypeName System.Collections.Generic.List[System.String]
$args.Add("/quiet")
$args.Add("/norestart")
Start-Process -FilePath $Path -ArgumentList $args -NoNewWindow -Wait -PassThru
Good luck!
Upvotes: 4