Skip to content
Browse files

Added script to configure IIS Logging settings

  • Loading branch information...
1 parent 4dca6e5 commit 6874fcb4c1cbb9806fa968f2a2a959e2f018d3ff @anurse anurse committed Oct 8, 2012
Showing with 55 additions and 14 deletions.
  1. +29 −0 Scripts/ConfigureIISLogging.cmd
  2. +1 −1 Scripts/Deploy.ps1
  3. +2 −0 Scripts/NuGetGallery.csdef
  4. +21 −11 Scripts/Package.ps1
  5. +2 −2 Website/Web.config
View
29 Scripts/ConfigureIISLogging.cmd
@@ -0,0 +1,29 @@
+@ECHO OFF
+
+echo Configuring IIS logging
+
+rem The set of fields that will be logged by IIS
+SET logfields=Date,Time,UserName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,TimeTaken,ServerPort,UserAgent,Referer,HttpSubStatus
+
+rem The appcmd executable
+SET appcmd=%windir%\system32\inetsrv\appcmd
+
+rem Retrieve all the sites, /xml flag allows output to be piped to next command
+SET getallsites=%appcmd% list sites /xml
+
+rem Set the logging fields for each site in the xml input (triggered by /in flag)
+SET setlogging=%appcmd% set site /in /logFile.logExtFileFlags:%logfields%
+
+rem Look for the string that indicates logging fields were set
+SET checkforsuccess=find "SITE object"
+
+:configlogstart
+%getallsites% | %setlogging% | %checkforsuccess%
+IF NOT ERRORLEVEL 1 goto configlogdone
+
+echo No site found, waiting 10 secs before retry... >> output.log
+TIMEOUT 10 > nul
+goto configlogstart
+
+:configlogdone
+echo Done configuring IIS logging >> output.log
View
2 Scripts/Deploy.ps1
@@ -106,5 +106,5 @@ if(!$UseEmulator) {
move-deployment -subscriptionId $subscriptionId -serviceName $serviceName -certificate $certificate -name $deploymentName
} else {
"Starting Emulator"
- & "$AzureToolsRoot\Emulator\CSRun.exe" "/run:$cspkgFile;$cscfgFile" /launchbrowser /devfabric /devstore /status /useiisexpress
+ & "$AzureToolsRoot\Emulator\CSRun.exe" "/run:$cspkgFile;$cscfgFile" /launchbrowser /devfabric /devstore /status
}
View
2 Scripts/NuGetGallery.csdef
@@ -3,6 +3,8 @@
<WebRole name="Website" vmsize="Medium">
<Startup>
<Task commandLine="EnableDynamicHttpCompression.cmd" executionContext="elevated" taskType="simple" />
+ <!-- Configure IIS Logging as a background task, since it will likely need to wait for the IIS site to be created -->
+ <Task commandLine="ConfigureIISLogging.cmd" executionContext="elevated" taskType="background" />
</Startup>
<Sites>
<Site name="Web">
View
32 Scripts/Package.ps1
@@ -27,8 +27,8 @@ $ScriptRoot = (Split-Path -parent $MyInvocation.MyCommand.Definition)
if(!$UseEmulator) {
require-param -value $azureStorageAccessKey -paramName "azureStorageAccessKey"
require-param -value $azureStorageAccountName -paramName "azureStorageAccountName"
- #require-param -value $azureDiagStorageAccessKey -paramName "azureDiagStorageAccessKey"
- #require-param -value $azureDiagStorageAccountName -paramName "azureDiagStorageAccountName"
+ require-param -value $azureDiagStorageAccessKey -paramName "azureDiagStorageAccessKey"
+ require-param -value $azureDiagStorageAccountName -paramName "azureDiagStorageAccountName"
require-param -value $azureStorageBlobUrl -paramName "azureStorageBlobUrl"
require-param -value $remoteDesktopAccountExpiration -paramName "remoteDesktopAccountExpiration"
require-param -value $remoteDesktopCertificateThumbprint -paramName "remoteDesktopCertificateThumbprint"
@@ -151,10 +151,12 @@ function remove-azmodule {
}
function remove-startuptask {
- param($path)
- "Removing Startup Task..."
+ param($path, $commandLine)
+ "Removing Startup Task $commandLine..."
$xml = [xml](get-content $path)
- $xml.ServiceDefinition.WebRole.Startup.RemoveAll()
+ $startup = $xml.ServiceDefinition.WebRole.Startup
+ $task = $startup.Task | where {$_.commandLine -eq $commandLine}
+ $startup.RemoveChild($task) | Out-Null
$resolvedPath = resolve-path($path)
$xml.save($resolvedPath)
}
@@ -197,9 +199,10 @@ $csdefBakPath = join-path $scriptPath "NuGetGallery.csdef.bak"
$cscfgPath = join-path $scriptPath "NuGetGallery.cscfg"
$cscfgBakPath = join-path $scriptPath "NuGetGallery.cscfg.bak"
$gitPath = (get-command git)
-$compressionCmdScriptsPath = join-path $scriptPath "EnableDynamicHttpCompression.cmd"
$binPath = join-path $websitePath "bin"
-$compressionCmdBinPath = join-path $binPath "EnableDynamicHttpCompression.cmd"
+
+# Startup Scripts
+$startupScripts = @("EnableDynamicHttpCompression.cmd", "ConfigureIISLogging.cmd")
if ($commitSha -eq $null) {
$commitSha = (& "$gitPath" rev-parse HEAD)
@@ -233,7 +236,7 @@ if(!$UseEmulator) {
set-connectionstring -path $webConfigPath -name "NuGetGallery" -value $sqlAzureConnectionString
set-certificatethumbprint -path $cscfgPath -name "nuget.org" -value $sslCertificateThumbprint
} else {
- remove-startuptask -path $csdefPath
+ remove-startuptask -path $csdefPath -commandLine "EnableDynamicHttpCompression.cmd"
remove-ssl -path $csdefPath
remove-azmodule -path $csdefPath -name "RemoteAccess"
remove-azmodule -path $csdefPath -name "RemoteForwarder"
@@ -265,22 +268,29 @@ if(!$UseEmulator) {
set-appsetting -path $webConfigPath -name "Gallery:UseAzureEmulator" -value "false"
}
-cp $compressionCmdScriptsPath $compressionCmdBinPath
+$startupScripts | ForEach-Object {
+ cp (Join-Path $scriptPath $_) (Join-Path $binPath $_)
+}
$copyOnlySwitch = ""
if($UseEmulator) {
$copyOnlySwitch = "/copyOnly"
}
& "$AzureToolsRoot\.NET SDK\2012-06\bin\cspack.exe" "$csdefPath" /useCtpPackageFormat /out:"$cspkgPath" /role:"Website;$websitePath" /sites:"Website;Web;$websitePath" /rolePropertiesFile:"Website;$rolePropertiesPath" $copyOnlySwitch
-if ($lastexitcode -ne 0) { exit 1 }
+if ($lastexitcode -ne 0) {
+ throw "CSPack Failed with Exit Code: $lastexitcode"
+ exit 1
+}
cp $cscfgPath $cspkgFolder
cp $webConfigBakPath $webConfigPath
cp $csdefBakPath $csdefPath
cp $cscfgBakPath $cscfgPath
-rm $compressionCmdBinPath
+$startupScripts | ForEach-Object {
+ rm (Join-Path $binPath $_)
+}
$packageDateTime = (Get-Date -format "MMMdd @ HHmm")
print-success("Azure $env:NUGET_GALLERY_ENV package and configuration dropped to $cspkgFolder.")
View
4 Website/Web.config
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
@@ -133,7 +133,7 @@
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
- <httpRuntime maxQueryStringLength="12000" maxRequestLength="2000000000" requestPathInvalidCharacters="&lt;,>,*,%,:,\,?" />
+ <httpRuntime maxQueryStringLength="12000" maxRequestLength="2000000000" requestPathInvalidCharacters="&lt;,&gt;,*,%,:,\,?" />
<httpModules>
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />

0 comments on commit 6874fcb

Please sign in to comment.
Something went wrong with that request. Please try again.