如何通过PowerShell在azure VM上安装ARR?

0 iis powershell azure

我已将我的项目部署到Azure Cloud Service,但另外我必须安装应用程序请求路由(ARR).

和平的.ps1 PowerShell命令:

if( Get-Service was ) {
        Write-Host "Stopping IIS and WAS..."
        Stop-Service was -Force
    }


    $filepath="%temp%\arr.msi"
    $process = (Start-Process -FilePath msiexec -ArgumentList /i, $filepath, /qn -Wait).ExitCode

    Write-Host $process
    if( Get-Service was ) {
        Start-Service was,w3svc -Verbose
    }
Run Code Online (Sandbox Code Playgroud)

输出:

正在下载MSI包...正在下载MSI包:D:\ Users\BUTTER~1\AppData\Local\Temp\2\arr.msi已下载...完成.执行安装...停止IIS和WAS ... 1619完成VERBOSE:在目标"万维网发布服务(w3svc)"上执行"启动服务"操作.VERBOSE:在Target"Windows Process Activation Service(was)"上执行"Start-Service"操作.

没有错误但它没有安装ARR.有人可以帮忙吗?

seb*_*aan 5

我无法通过PowerShell直接找到这样做的好方法.如果您不介意使用Chocolatey,可以从Web平台安装程序命令行(WebPICMD)完成所有操作,例如:

#Download and install Chocolatey and through Chocolatey install WebPICMD
iex ((new-object net.webclient).DownloadString("https://chocolatey.org/install.ps1"))
cinst webpicommandline

#Install Url Rewrite and ARR
$webPiProducts = @('UrlRewrite2', 'ARRv3_0') 
WebPICMD /Install /Products:"$($webPiProducts -join ',')" /AcceptEULA
Run Code Online (Sandbox Code Playgroud)

有关WebPICMD的更多信息,请访问:http://www.iis.net/learn/install/web-platform-installer/web-platform-installer-v4-command-line-webpicmdexe-rtw-release

灵感来自这篇博文:http://www.tugberkugurlu.com/archive/script-out-everything-initialize-your-windows-azure-vm-for-your-web-server-with-iis-web -deploy-和其他-东西