URL重写器Powershell DSC

问题描述 投票:2回答:1

我正在尝试使用Powershell DSC安装URL重写器并且它一直在失败。当我删除安装重写器的步骤时,脚本会成功。

我的设置是使用Visual Studio Team Services(VSTS)构建和发布管道我执行ARM模板来创建一个缩放集,指向powershell dsc脚本。

"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')]"
                    }
                }
            }
        }
    ]
}

在这个脚本中,我正在启用Windows功能,安装Web部署和URL重写器。当没有安装重写器时一切正常,但是当我以下列任何一种方式添加它时失败。

DSC脚本实际上看起来像:

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
}

我直接从quickstart示例中获取了这个:

    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"
    }

上面的失败带有令人烦恼的模糊错误

{
  "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.\"."
      }
    ]
  }
}

所以我试着以这种方式下载并安装软件包

#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"
}

在这种情况下,下载确实有效,并且在目录中找到了msi。但是,它不会安装URL重写器并且无法部署。

我添加了一个用于记录的参数,但不确定错误是什么。

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"
    }

这是与错误相关的日志的一部分,似乎没有任何其他相关内容。

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

我试图手动安装它以查看会发生什么,并且它在同一消息中出错,但显然安装了IIS。现在我想知道2016-Datacenter或IIS 10是否是问题所在。

enter image description here

powershell azure url-rewrite-module dsc azure-vm-scale-set
1个回答
5
投票

似乎快速启动模板中使用的URL Rewrite版本不适用于2016-Datacenter最新版本。

"imageReference": {
    "publisher": "MicrosoftWindowsServer",
    "offer": "WindowsServer",
    "sku": "2016-Datacenter",
    "version": "latest"
}

使用这个版本似乎工作

## IIS URL Rewrite module download and install
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/D/D/E/DDE57C26-C62C-4C59-A1BB-31D58B36ADA2/rewrite_amd64_en-US.msi"
    Arguments = '/L*V "C:\WindowsAzure\urlrewriter.txt" /quiet'
    ProductId = "38D32370-3A31-40E9-91D0-D236F47E3C4A"
}
© www.soinside.com 2019 - 2024. All rights reserved.