启用磁盘缓存时出现Azure ARR错误

时间:2013-04-25 10:14:47

标签: azure iis-7.5 arr

我们有天蓝色托管服务,现在我需要在其上设置ARR(应用程序请求路由)。我关注了博客http://robindotnet.wordpress.com/2011/07/,ARR工作正常。现在我需要为此启用diskCaching,我正在尝试下面的命令:

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/diskCache /+"[path='c:\cache',maxUsage='0']" /commit:apphost >> C:\setDiskCache.txt

但是低于错误:     错误(消息:新的driveLocation对象缺少必需的属性。无法添加类型为'driveLocation'的重复集合条目,并且唯一键属性'path'设置为'c:\ cache'。)

并且没有内容缓存在此文件夹中。任何方向或帮助都表示赞赏。

以下是完整的cmd文件供参考:

cd /d "%~dp0"

start /wait msiexec.exe /i webfarm_amd64_en-US.msi /qn /log C:\installWebfarmLog.txt
start /wait msiexec.exe /i requestRouter_amd64_en-US.msi /qn /log C:\installARRLog.txt

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy /enabled:"True" /reverseRewriteHostInResponseHeaders:"False" /preserveHostHeader:"True" /commit:apphost >> C:\setProxyLog.txt

%windir%\system32\inetsrv\appcmd.exe set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00 >> C:\setAppPool.txt

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/diskCache /+"[path='c:\cache',maxUsage='0']" /commit:apphost >> C:\setDiskCache.txt

exit /b 0

我可以在IIS找到相同的东西[http://www.iis.net/learn/extensions/configuring-application-request-routing-(arr)/configure-and-enable-disk-cache-in -application-request-routing],可以手动启用。但我们需要以编程方式启用它。

1 个答案:

答案 0 :(得分:1)

通常情况下,错误消息会提示原因。问题是每个驱动器位置值只能有一个条目。这意味着脚本第一次运行正常,但第二次它将抛出,因为该值已经应用。

您无法使用appcmd删除节点(它不支持清除集合),但您可以使用文本编辑器(此文件:%windir%\ System32 \ inetsrv \ config \ applicationHost.config)。或者您可以运行powershell脚本:

Import-Module WebAdministration
Remove-WebConfigurationProperty  -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/diskCache" -name "."

在任何一种情况下,这都是将被操纵的节点:

<driveLocation path="c:\cache" maxUsage="0" />

之后,您将能够重新运行代码。

相关问题