Permalink
Browse files

Added support for building a package for use in the development fabric

  • Loading branch information...
1 parent 045465e commit ba8616f635ad1a91c23f083d926ed4a74df067ca @anurse anurse committed Sep 29, 2012
View
@@ -10,12 +10,13 @@
$ScriptRoot = (Split-Path -parent $MyInvocation.MyCommand.Definition)
. $ScriptRoot\_Common.ps1
-require-param -value $subscriptionId -paramName "subscriptionId"
-require-param -value $serviceName -paramName "serviceName"
-require-param -value $storageServiceName -paramName "storageServiceName"
-require-param -value $certificateThumbprint -paramName "certificateThumbprint"
-
-require-module -name "WAPPSCmdlets"
+if(!$UseEmulator) {
+ require-param -value $subscriptionId -paramName "subscriptionId"
+ require-param -value $serviceName -paramName "serviceName"
+ require-param -value $storageServiceName -paramName "storageServiceName"
+ require-param -value $certificateThumbprint -paramName "certificateThumbprint"
+ require-module -name "Azure"
+}
function await-operation($operationId)
{
@@ -68,8 +69,10 @@ $gitPath = $gitCommand.Definition
if ($commitRevision -eq $null) { $commitRevision = (& "$gitPath" rev-parse --short HEAD) }
if ($commitBranch -eq $null) { $commitBranch = (& "$gitPath" name-rev --name-only HEAD) }
-"Getting Azure management certificate $certificateThumbprint"
-$certificate = (get-item cert:\CurrentUser\MY\$certificateThumbprint)
+if(!$UseEmulator) {
+ "Getting Azure management certificate $certificateThumbprint"
+ $certificate = (get-item cert:\CurrentUser\MY\$certificateThumbprint)
+}
"Building deployment name from date and revision"
$deploymentLabel = "$((get-date).ToString("MMM dd @ HHmm")) ($commitRevision on $commitBranch; auto-deployed)"
@@ -80,24 +83,28 @@ $packageLocation = join-path (resolve-path(join-path $ScriptRoot "..")) "_AzureP
$cspkgFile = join-path $packageLocation "NuGetGallery.cspkg"
$cscfgFile = join-path $packageLocation "NuGetGallery.cscfg"
-"Checking for existing staging deployment on $serviceName"
-$deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
-if ($deployment -ne $null -and $deployment.Name -ne $null) {
- "Deleting existing staging deployment $($deployment.Name) on $serviceName"
- $operationId = (remove-deployment -subscriptionId $subscriptionId -certificate $certificate -slot Staging -serviceName $serviceName ).operationId
- await-operation($operationId)
-}
-
-"Creating new staging deployment $deploymentName on $serviceName"
-$operationId = (new-deployment -subscriptionId $subscriptionId -certificate $certificate -ServiceName $serviceName -storageServiceName $storageServiceName -slot Staging -Package $cspkgFile -Configuration $cscfgFile -Name $deploymentName -Label $deploymentLabel).operationId
-await-operation($operationId)
-await-status("Suspended")
-
-"Starting staging deployment $deploymentName on $serviceName"
-$operationId = (set-deploymentstatus -subscriptionId $subscriptionId -serviceName $serviceName -slot Staging -status Running -certificate $certificate).operationId
-await-operation($operationId)
-await-start
-
-"Moving staging deployment $deploymentName to productionon on $serviceName"
-move-deployment -subscriptionId $subscriptionId -serviceName $serviceName -certificate $certificate -name $deploymentName
-
+if(!$UseEmulator) {
+ "Checking for existing staging deployment on $serviceName"
+ $deployment = Get-Deployment -ServiceName $serviceName -Slot Staging -Certificate $certificate -SubscriptionId $subscriptionId
+ if ($deployment -ne $null -and $deployment.Name -ne $null) {
+ "Deleting existing staging deployment $($deployment.Name) on $serviceName"
+ $operationId = (remove-deployment -subscriptionId $subscriptionId -certificate $certificate -slot Staging -serviceName $serviceName ).operationId
+ await-operation($operationId)
+ }
+
+ "Creating new staging deployment $deploymentName on $serviceName"
+ $operationId = (new-deployment -subscriptionId $subscriptionId -certificate $certificate -ServiceName $serviceName -storageServiceName $storageServiceName -slot Staging -Package $cspkgFile -Configuration $cscfgFile -Name $deploymentName -Label $deploymentLabel).operationId
+ await-operation($operationId)
+ await-status("Suspended")
+
+ "Starting staging deployment $deploymentName on $serviceName"
+ $operationId = (set-deploymentstatus -subscriptionId $subscriptionId -serviceName $serviceName -slot Staging -status Running -certificate $certificate).operationId
+ await-operation($operationId)
+ await-start
+
+ "Moving staging deployment $deploymentName to productionon on $serviceName"
+ 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
+}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<ServiceDefinition name="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
+<ServiceDefinition name="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
<WebRole name="Website" vmsize="Medium">
<Startup>
<Task commandLine="EnableDynamicHttpCompression.cmd" executionContext="elevated" taskType="simple" />
@@ -16,6 +16,9 @@
<InputEndpoint name="Non-SSL" protocol="http" port="80" />
<InputEndpoint name="SSL" protocol="https" port="443" certificate="nuget.org" />
</Endpoints>
+ <LocalResources>
+ <LocalStorage name="IISLogs" sizeInMB="1024" cleanOnRoleRecycle="false" />
+ </LocalResources>
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
View
@@ -22,19 +22,21 @@ $ScriptRoot = (Split-Path -parent $MyInvocation.MyCommand.Definition)
. $ScriptRoot\_Common.ps1
#Validate Sutff
-require-param -value $azureStorageAccessKey -paramName "azureStorageAccessKey"
-require-param -value $azureStorageAccountName -paramName "azureStorageAccountName"
-require-param -value $azureStorageBlobUrl -paramName "azureStorageBlobUrl"
-require-param -value $remoteDesktopAccountExpiration -paramName "remoteDesktopAccountExpiration"
-require-param -value $remoteDesktopCertificateThumbprint -paramName "remoteDesktopCertificateThumbprint"
-require-param -value $remoteDesktopEnctyptedPassword -paramName "remoteDesktopEnctyptedPassword"
-require-param -value $remoteDesktopUsername -paramName "remoteDesktopUsername"
-require-param -value $sqlAzureConnectionString -paramName "sqlAzureConnectionString"
-require-param -value $sslCertificateThumbprint -paramName "sslCertificateThumbprint"
-require-param -value $validationKey -paramName "validationKey"
-require-param -value $decryptionKey -paramName "decryptionKey"
-require-param -value $vmSize -paramName "vmSize"
-require-param -value $googleAnalyticsPropertyId -paramName "googleAnalyticsPropertyId"
+if(!$UseEmulator) {
+ require-param -value $azureStorageAccessKey -paramName "azureStorageAccessKey"
+ require-param -value $azureStorageAccountName -paramName "azureStorageAccountName"
+ require-param -value $azureStorageBlobUrl -paramName "azureStorageBlobUrl"
+ require-param -value $remoteDesktopAccountExpiration -paramName "remoteDesktopAccountExpiration"
+ require-param -value $remoteDesktopCertificateThumbprint -paramName "remoteDesktopCertificateThumbprint"
+ require-param -value $remoteDesktopEnctyptedPassword -paramName "remoteDesktopEnctyptedPassword"
+ require-param -value $remoteDesktopUsername -paramName "remoteDesktopUsername"
+ require-param -value $sqlAzureConnectionString -paramName "sqlAzureConnectionString"
+ require-param -value $sslCertificateThumbprint -paramName "sslCertificateThumbprint"
+ require-param -value $validationKey -paramName "validationKey"
+ require-param -value $decryptionKey -paramName "decryptionKey"
+ require-param -value $vmSize -paramName "vmSize"
+ require-param -value $googleAnalyticsPropertyId -paramName "googleAnalyticsPropertyId"
+}
#Helper Functions
function set-certificatethumbprint {
@@ -89,6 +91,70 @@ function set-vmsize {
$xml.save($resolvedPath)
}
+function set-instancecount {
+ param($path, $count)
+ $xml = [xml](get-content $path)
+ $instances = $xml.ServiceConfiguration.Role.Instances
+ $instances.count = $count.ToString()
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
+function remove-ssl {
+ param($path)
+ "Removing Azure SSL Settings..."
+ $xml = [xml](get-content $path)
+ $bindings = $xml.ServiceDefinition.WebRole.Sites.Site.Bindings
+ $sslBinding = $xml.ServiceDefinition.WebRole.Sites.Site.Bindings.Binding | where {$_.name -eq "SSLBinding"}
+ $bindings.RemoveChild($sslBinding) | Out-Null
+ $endpoints = $xml.ServiceDefinition.WebRole.Endpoints
+ $sslEndpoint = $xml.ServiceDefinition.WebRole.Endpoints.InputEndpoint | where {$_.name -eq "SSL"}
+ $endpoints.RemoveChild($sslEndpoint) | Out-Null
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
+function remove-setting {
+ param($path, $name)
+ "Removing Azure Setting $name..."
+ $xml = [xml](get-content $path)
+ $settings = $xml.ServiceConfiguration.Role.ConfigurationSettings
+ $toRemove = $settings.Setting | where {$_.name -eq $name}
+ $settings.RemoveChild($toRemove) | Out-Null
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
+function remove-certificates {
+ param($path)
+ "Removing Azure Certificates..."
+ $xml = [xml](get-content $path)
+ $settings = $xml.ServiceConfiguration.Role.Certificates
+ $settings.RemoveAll() | Out-Null
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
+function remove-azmodule {
+ param($path, $name)
+ "Removing Azure Module $name..."
+ $xml = [xml](get-content $path)
+ $modules = $xml.ServiceDefinition.WebRole.Imports
+ $toRemove = $modules.Import | where {$_.moduleName -eq $name}
+ $modules.RemoveChild($toRemove) | Out-Null
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
+function remove-startuptask {
+ param($path)
+ "Removing Startup Task..."
+ $xml = [xml](get-content $path)
+ $xml.ServiceDefinition.WebRole.Startup.RemoveAll()
+ $resolvedPath = resolve-path($path)
+ $xml.save($resolvedPath)
+}
+
function set-releasemode {
param($path)
$xml = [xml](get-content $path)
@@ -150,32 +216,53 @@ cp $webConfigPath $webConfigBakPath
cp $csdefPath $csdefBakPath
cp $cscfgPath $cscfgBakPath
-set-vmsize -path $csdefPath -size $vmSize
-set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" -value $remoteDesktopAccountExpiration
-set-certificatethumbprint -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" -value $remoteDesktopCertificateThumbprint
-set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" -value $remoteDesktopEnctyptedPassword
-set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" -value $remoteDesktopUsername
-set-connectionstring -path $webConfigPath -name "NuGetGallery" -value $sqlAzureConnectionString
-set-certificatethumbprint -path $cscfgPath -name "nuget.org" -value $sslCertificateThumbprint
+if(!$UseEmulator) {
+ set-vmsize -path $csdefPath -size $vmSize
+ set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" -value $remoteDesktopAccountExpiration
+ set-certificatethumbprint -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" -value $remoteDesktopCertificateThumbprint
+ set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" -value $remoteDesktopEnctyptedPassword
+ set-configurationsetting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" -value $remoteDesktopUsername
+ set-connectionstring -path $webConfigPath -name "NuGetGallery" -value $sqlAzureConnectionString
+ set-certificatethumbprint -path $cscfgPath -name "nuget.org" -value $sslCertificateThumbprint
+} else {
+ remove-startuptask -path $csdefPath
+ remove-ssl -path $csdefPath
+ remove-azmodule -path $csdefPath -name "RemoteAccess"
+ remove-azmodule -path $csdefPath -name "RemoteForwarder"
+ remove-setting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled"
+ remove-setting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled"
+ remove-setting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration"
+ remove-certificates -path $cscfgPath
+ remove-setting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword"
+ remove-setting -path $cscfgPath -name "Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername"
+ set-instancecount -path $cscfgPath -count 1
+}
set-releasemode $webConfigPath
set-machinekey $webConfigPath
#Release Tag stuff
print-message("Setting the release tags")
-set-appsetting -path $webConfigPath -name "Gallery:AzureStorageAccessKey" -value $azureStorageAccessKey
-set-appsetting -path $webConfigPath -name "Gallery:AzureStorageAccountName" -value $azureStorageAccountName
-set-appsetting -path $webConfigPath -name "Gallery:AzureStorageBlobUrl" -value $azureStorageBlobUrl
-set-appsetting -path $webConfigPath -name "Gallery:AzureCdnHost" -value $azureCdnHost
-set-appsetting -path $webConfigPath -name "Gallery:GoogleAnalyticsPropertyId" -value $googleAnalyticsPropertyId
-set-appsetting -path $webConfigPath -name "Gallery:PackageStoreType" -value "AzureStorageBlob"
-set-appsetting -path $webConfigPath -name "Gallery:ReleaseBranch" -value $commitBranch
-set-appsetting -path $webConfigPath -name "Gallery:ReleaseName" -value "NuGet 1.6 'Hershey'"
-set-appsetting -path $webConfigPath -name "Gallery:ReleaseSha" -value $commitSha
-set-appsetting -path $webConfigPath -name "Gallery:ReleaseTime" -value (Get-Date -format "dd/MM/yyyy HH:mm:ss")
+if(!$UseEmulator) {
+ set-appsetting -path $webConfigPath -name "Gallery:AzureStorageAccessKey" -value $azureStorageAccessKey
+ set-appsetting -path $webConfigPath -name "Gallery:AzureStorageAccountName" -value $azureStorageAccountName
+ set-appsetting -path $webConfigPath -name "Gallery:AzureStorageBlobUrl" -value $azureStorageBlobUrl
+ set-appsetting -path $webConfigPath -name "Gallery:AzureCdnHost" -value $azureCdnHost
+ set-appsetting -path $webConfigPath -name "Gallery:GoogleAnalyticsPropertyId" -value $googleAnalyticsPropertyId
+ set-appsetting -path $webConfigPath -name "Gallery:PackageStoreType" -value "AzureStorageBlob"
+ set-appsetting -path $webConfigPath -name "Gallery:ReleaseBranch" -value $commitBranch
+ set-appsetting -path $webConfigPath -name "Gallery:ReleaseName" -value "NuGet 1.6 'Hershey'"
+ set-appsetting -path $webConfigPath -name "Gallery:ReleaseSha" -value $commitSha
+ set-appsetting -path $webConfigPath -name "Gallery:ReleaseTime" -value (Get-Date -format "dd/MM/yyyy HH:mm:ss")
+}
cp $compressionCmdScriptsPath $compressionCmdBinPath
-& 'C:\Program Files\Windows Azure SDK\v1.6\bin\cspack.exe' "$csdefPath" /out:"$cspkgPath" /role:"Website;$websitePath" /sites:"Website;Web;$websitePath" /rolePropertiesFile:"Website;$rolePropertiesPath"
+$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 }
cp $cscfgPath $cspkgFolder
Binary file not shown.
View
@@ -51,4 +51,7 @@ function programfiles-dir {
function is64bit() {
return ([IntPtr]::Size -eq 8)
-}
+}
+
+$AzureToolsRoot = "C:\Program Files\Microsoft SDKs\Windows Azure\"
+$UseEmulator = $env:NUGET_USE_EMULATOR -eq $true
@@ -62,6 +62,14 @@ public string AzureStorageBlobUrl
}
}
+ public bool UseEmulator
+ {
+ get
+ {
+ return String.Equals(ReadAppSettings("UseAzureEmulator"), "true", StringComparison.OrdinalIgnoreCase);
+ }
+ }
+
public string FileStorageDirectory
{
get
@@ -148,7 +148,9 @@ public override void Load()
Bind<ICloudBlobClient>()
.ToMethod(context => new CloudBlobClientWrapper(new CloudBlobClient(
new Uri(configuration.AzureStorageBlobUrl, UriKind.Absolute),
- new StorageCredentialsAccountAndKey(configuration.AzureStorageAccountName, configuration.AzureStorageAccessKey))))
+ configuration.UseEmulator ?
+ CloudStorageAccount.DevelopmentStorageAccount.Credentials :
+ new StorageCredentialsAccountAndKey(configuration.AzureStorageAccountName, configuration.AzureStorageAccessKey))))
.InSingletonScope();
Bind<IFileStorageService>()
.To<CloudBlobFileStorageService>()
@@ -9,6 +9,7 @@ public interface IConfiguration
string FileStorageDirectory { get; }
string AzureCdnHost { get; }
PackageStoreType PackageStoreType { get; }
+ bool UseEmulator { get; }
string GetSiteRoot(bool useHttps);
}
View
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<DiagnosticMonitorConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration"
+ configurationChangePollInterval="PT1M"
+ overallQuotaInMB="4096">
+ <DiagnosticInfrastructureLogs bufferQuotaInMB="512"
+ scheduledTransferLogLevelFilter="Verbose"
+ scheduledTransferPeriod="PT1M" />
+ <Logs bufferQuotaInMB="512"
+ scheduledTransferLogLevelFilter="Verbose"
+ scheduledTransferPeriod="PT1M" />
+ <Directories bufferQuotaInMB="512"
+ scheduledTransferPeriod="PT1M">
+
+ <!-- These three elements specify the special directories
+ that are set up for the log types -->
+ <CrashDumps container="wad-crash-dumps" directoryQuotaInMB="256" />
+ <FailedRequestLogs container="wad-frq" directoryQuotaInMB="256" />
+ <IISLogs container="wad-iis" directoryQuotaInMB="256" />
+ </Directories>
+ <PerformanceCounters bufferQuotaInMB="512" scheduledTransferPeriod="PT1M">
+ <!-- The counter specifier is in the same format as the imperative
+ diagnostics configuration API -->
+ <PerformanceCounterConfiguration
+ counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT5S" />
+ </PerformanceCounters>
+ <WindowsEventLog bufferQuotaInMB="512"
+ scheduledTransferLogLevelFilter="Verbose"
+ scheduledTransferPeriod="PT1M">
+ <!-- The event log name is in the same format as the imperative
+ diagnostics configuration API -->
+ <DataSource name="System!*" />
+ </WindowsEventLog>
+</DiagnosticMonitorConfiguration>
Oops, something went wrong.

0 comments on commit ba8616f

Please sign in to comment.