Skip to content
Browse files

removed app-specific config from Azure cscfg to make it easier to run…

… against preview settings locally
  • Loading branch information...
1 parent da9fee5 commit 953c942457672b54c741a3dc559860bc36ee0120 @half-ogre half-ogre committed Jun 11, 2012
Showing with 31 additions and 72 deletions.
  1. +0 −5 Scripts/NuGetGallery.cscfg
  2. +0 −7 Scripts/NuGetGallery.csdef
  3. +6 −5 Scripts/Package.ps1
  4. +18 −51 Website/App_Start/Configuration.cs
  5. +7 −4 Website/Web.config
View
5 Scripts/NuGetGallery.cscfg
@@ -9,11 +9,6 @@
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
- <Setting name="AzureStorageAccessKey" value="" />
- <Setting name="AzureStorageAccountName" value="" />
- <Setting name="AzureStorageBlobUrl" value="" />
- <Setting name="PackageStoreType" value="AzureStorageBlob" />
- <Setting name="UseSmtp" value="true" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="" thumbprintAlgorithm="sha1" />
View
7 Scripts/NuGetGallery.csdef
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="Website" vmsize="Medium">
- <ConfigurationSettings>
- <Setting name="AzureStorageAccessKey" />
- <Setting name="AzureStorageAccountName" />
- <Setting name="AzureStorageBlobUrl" />
- <Setting name="PackageStoreType" />
- <Setting name="UseSmtp" />
- </ConfigurationSettings>
<Startup>
<Task commandLine="EnableDynamicHttpCompression.cmd" executionContext="elevated" taskType="simple" />
</Startup>
View
11 Scripts/Package.ps1
@@ -141,9 +141,6 @@ cp $csdefPath $csdefBakPath
cp $cscfgPath $cscfgBakPath
set-vmsize -path $csdefPath -size $vmSize
-set-configurationsetting -path $cscfgPath -name "AzureStorageAccessKey" -value $azureStorageAccessKey
-set-configurationsetting -path $cscfgPath -name "AzureStorageAccountName" -value $azureStorageAccountName
-set-configurationsetting -path $cscfgPath -name "AzureStorageBlobUrl" -value $azureStorageBlobUrl
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
@@ -155,11 +152,15 @@ 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: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:ReleaseTime" -value (Get-Date -format "dd/MM/yyyy HH:mm:ss")
set-appsetting -path $webConfigPath -name "Gallery:ReleaseSha" -value $commitSha
-set-appsetting -path $webConfigPath -name "Gallery:ReleaseBranch" -value $commitBranch
+set-appsetting -path $webConfigPath -name "Gallery:ReleaseTime" -value (Get-Date -format "dd/MM/yyyy HH:mm:ss")
cp $compressionCmdScriptsPath $compressionCmdBinPath
View
69 Website/App_Start/Configuration.cs
@@ -1,123 +1,90 @@
using System;
using System.Collections.Generic;
using System.Configuration;
-using System.Diagnostics;
using System.Web;
-using Microsoft.WindowsAzure.ServiceRuntime;
namespace NuGetGallery
{
public class Configuration : IConfiguration
{
- private static readonly Dictionary<string, Lazy<object>> configThunks = new Dictionary<string, Lazy<object>>();
+ private static readonly Dictionary<string, Lazy<object>> _configThunks = new Dictionary<string, Lazy<object>>();
private readonly Lazy<string> _httpSiteRootThunk;
private readonly Lazy<string> _httpsSiteRootThunk;
- static readonly Lazy<bool> runningInAzure = new Lazy<bool>(RunningInAzure);
public Configuration()
{
_httpSiteRootThunk = new Lazy<string>(GetHttpSiteRoot);
_httpsSiteRootThunk = new Lazy<string>(GetHttpsSiteRoot);
}
- public static string ReadAppSetting(string key)
+ public static string ReadAppSettings(string key)
{
- var value = ConfigurationManager.AppSettings[key];
- return value;
+ return ReadAppSettings(key, value => value);
}
- public static string ReadAzureSetting(string key)
- {
- return RoleEnvironment.GetConfigurationSettingValue(key);
- }
-
- public static string ReadConfiguration(string key)
- {
- return ReadConfiguration<string>(
- key,
- value => value);
- }
-
- public static T ReadConfiguration<T>(
+ public static T ReadAppSettings<T>(
string key,
Func<string, T> valueThunk)
{
- if (!configThunks.ContainsKey(key))
- configThunks.Add(key, new Lazy<object>(() =>
+ if (!_configThunks.ContainsKey(key))
+ _configThunks.Add(key, new Lazy<object>(() =>
{
- string value = null;
-
- if (runningInAzure.Value)
- value = ReadAzureSetting(key);
-
- if (value == null)
- value = ReadAppSetting(key);
-
+ var value = ConfigurationManager.AppSettings[string.Format("Gallery:{0}", key)];
+ if (string.IsNullOrWhiteSpace(value))
+ value = null;
return valueThunk(value);
}));
- return (T)configThunks[key].Value;
- }
-
- static bool RunningInAzure()
- {
- try
- {
- return RoleEnvironment.IsAvailable;
- }
- catch (RoleEnvironmentException) { }
- catch (TypeInitializationException) { }
-
- return false;
+ return (T)_configThunks[key].Value;
}
public string AzureStorageAccessKey
{
get
{
- return ReadConfiguration("AzureStorageAccessKey");
+ return ReadAppSettings("AzureStorageAccessKey");
}
}
public string AzureStorageAccountName
{
get
{
- return ReadConfiguration("AzureStorageAccountName");
+ return ReadAppSettings("AzureStorageAccountName");
}
}
public string AzureStorageBlobUrl
{
get
{
- return ReadConfiguration("AzureStorageBlobUrl");
+ return ReadAppSettings("AzureStorageBlobUrl");
}
}
public string FileStorageDirectory
{
get
{
- return ReadConfiguration<string>(
+ return ReadAppSettings(
"FileStorageDirectory",
- (value) => value ?? HttpContext.Current.Server.MapPath("~/App_Data/Files"));
+ value => value ?? HttpContext.Current.Server.MapPath("~/App_Data/Files"));
}
}
public PackageStoreType PackageStoreType
{
get
{
- return ReadConfiguration<PackageStoreType>(
+ return ReadAppSettings(
"PackageStoreType",
- (value) => (PackageStoreType)Enum.Parse(typeof(PackageStoreType), value ?? PackageStoreType.NotSpecified.ToString()));
+ value => (PackageStoreType)Enum.Parse(typeof(PackageStoreType), value ?? PackageStoreType.NotSpecified.ToString()));
}
}
protected virtual string GetConfiguredSiteRoot()
{
- return ConfigurationManager.AppSettings["Configuration:SiteRoot"];
+ return ReadAppSettings("SiteRoot");
}
protected virtual HttpRequestBase GetCurrentRequest()
View
11 Website/Web.config
@@ -17,13 +17,16 @@
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
- <add key="GalleryOwnerEmail" value="NuGet.org Gallery &lt;nugetgallery@outercurve.org&gt;" />
+ <add key="Gallery:AzureStorageAccessKey" value="" />
+ <add key="Gallery:AzureStorageAccountName" value="" />
+ <add key="Gallery:AzureStorageBlobUrl" value="" />
+ <add key="Gallery:GoogleAnalyticsPropertyId" value="" />
+ <add key="Gallery:PackageStoreType" value="" />
+ <add key="Gallery:ReleaseBranch" value="" />
<add key="Gallery:ReleaseName" value="" />
<add key="Gallery:ReleaseSha" value="" />
- <add key="Gallery:ReleaseBranch" value="" />
<add key="Gallery:ReleaseTime" value="" />
- <add key="Gallery:GoogleAnalyticsPropertyId" value="" />
- <add key="Configuration:SiteRoot" value="http://nuget.org/" />
+ <add key="Gallery:SiteRoot" value="http://nuget.org/" />
</appSettings>
<connectionStrings>
<add name="NuGetGallery" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=NuGetGallery;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

0 comments on commit 953c942

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