I'm trying to get the URL Rewriter installed using Powershell DSC and it keeps failing. When I remove the step for installing rewriter, the script succeeds.
My setup is using Visual Studio Team Services (VSTS) build and release pipeline I execute an ARM template to create a scale set, pointing to a powershell dsc script.
"extensionProfile": {
"extensions": [
{
"name": "Microsoft.Powershell.DSC",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.72",
"autoUpgradeMinorVersion": true,
"forceUpdateTag": "[parameters('dscVmssUpdateTagVersion')]",
"settings": {
"configuration": {
"url": "https://myblobname.blob.core.windows.net/dsc/scalesetSetup.zip",
"script": "prepareServer.ps1",
"function": "PrepareServer"
},
"configurationArguments": {
"nodeName": "localhost",
"envName": "[parameters('envName')]"
}
}
}
}
]
}
in this script, I'm enabling windows features, installing Web Deploy and URL Rewriter. Everything works when rewriter is not being installed, but fails when I add it back in either of the following ways.
The DSC script effectively looks like:
Configuration PrepareServer
{
Param ( [string] $nodeName, [string] $envName )
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node $nodeName
{
# Web Server
WindowsFeature WebServerRole
{
Name = "Web-Server"
Ensure = "Present"
}
## other features ...
Script DownloadWebDeploy
{
TestScript = {
Test-Path "C:\WindowsAzure\WebDeploy_amd64_en-US.msi"
}
SetScript ={
$source = "https://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi"
$dest = "C:\WindowsAzure\WebDeploy_amd64_en-US.msi"
Invoke-WebRequest $source -OutFile $dest
}
GetScript = {@{Result = "DownloadWebDeploy"}}
DependsOn = "[WindowsFeature]WebServerRole"
}
Package InstallWebDeploy
{
Ensure = "Present"
Path = "C:\WindowsAzure\WebDeploy_amd64_en-US.msi"
Name = "Microsoft Web Deploy 3.6"
ProductId = "{6773A61D-755B-4F74-95CC-97920E45E696}"
Arguments = "ADDLOCAL=ALL"
DependsOn = "[Script]DownloadWebDeploy"
}
Service StartWebDeploy
{
Name = "WMSVC"
StartupType = "Automatic"
State = "Running"
DependsOn = "[Package]InstallWebDeploy"
}
## attempt to install UrlRewrite here
}
I took this directly from a quickstart example:
Package UrlRewrite
{
#Install URL Rewrite module for IIS
DependsOn = "[WindowsFeature]WebServerRole"
Ensure = "Present"
Name = "IIS URL Rewrite Module 2"
Path = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi"
Arguments = "/quiet"
ProductId = "EB675D0A-2C95-405B-BEE8-B42A65D23E11"
}
The above fails with an annoyingly vague error
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "VMExtensionProvisioningError",
"message": "VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \"DSC Configuration 'PrepareServer' completed with error(s). Following are the first few: PowerShell DSC resource MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1603 was not expected. Configuration is likely not correct The SendConfigurationApply function did not succeed.\"."
}
]
}
}
So I tried to just download and install the package this way
#download works, install does not
Script DownloadUrlRewrite
{
TestScript = {
Test-Path "C:\WindowsAzure\rewrite_2.0_rtw_x64.msi"
}
SetScript ={
$source = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi"
$dest = "C:\WindowsAzure\rewrite_2.0_rtw_x64.msi"
Invoke-WebRequest $source -OutFile $dest
}
GetScript = {@{Result = "DownloadUrlRewrite"}}
DependsOn = "[WindowsFeature]WebServerRole"
}
Package InstallUrlRewrite
{
Ensure = "Present"
Path = "C:\WindowsAzure\rewrite_2.0_rtw_x64.msi"
Name = "IIS URL Rewrite Module 2"
ProductId = "{EB675D0A-2C95-405B-BEE8-B42A65D23E11}"
Arguments = "/quiet"
DependsOn = "[Script]DownloadUrlRewrite"
}
In this case, the download does work and the msi is found in the directory. However, it does not install the url rewriter and fails deployment.
I added an argument for logging, but not sure what the error is still.
Package UrlRewrite
{
#Install URL Rewrite module for IIS
DependsOn = "[WindowsFeature]WebServerRole"
Ensure = "Present"
Name = "IIS URL Rewrite Module 2"
Path = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi"
Arguments = '/L*V "C:\WindowsAzure\urlrewriter.txt" /quiet'
ProductId = "EB675D0A-2C95-405B-BEE8-B42A65D23E11"
}
Here is a part of the log related to errors, nothing else seemed relevant.
Action ended 23:54:42: AppSearch. Return value 1.
Action start 23:54:42: FindRelatedProducts.
MSI (s) (C4:B4) [23:54:42:549]: Doing action: LaunchConditions
Action ended 23:54:42: FindRelatedProducts. Return value 1.
Action start 23:54:42: LaunchConditions.
MSI (s) (C4:B4) [23:54:42:549]: Product: IIS URL Rewrite Module 2 -- IIS
Version 7.0 or greater is required to install IIS URL Rewrite Module 2.
IIS Version 7.0 or greater is required to install IIS URL Rewrite Module 2.
Action ended 23:54:42: LaunchConditions. Return value 3.
Action ended 23:54:42: INSTALL. Return value 3.
... bunch of Property(S): stuffs...
MSI (s) (C4:B4) [23:54:42:565]: Note: 1: 1708
MSI (s) (C4:B4) [23:54:42:565]: Product: IIS URL Rewrite Module 2 -- Installation failed.
MSI (s) (C4:B4) [23:54:42:565]: Windows Installer installed the product. Product
Name: IIS URL Rewrite Module 2. Product Version: 7.2.2. Product Language: 1033. Manufacturer: Microsoft Corporation. Installation success or error status: 1603.
MSI (s) (C4:B4) [23:54:42:565]: Deferring clean up of packages/files, if any exist
MSI (s) (C4:B4) [23:54:42:565]: MainEngineThread is returning 1603
I tried to just manually install it to see what would happen and it did error with the same message, but clearly IIS is installed. Now I'm wondering if it's 2016-Datacenter or IIS 10 that is the problem.