public static void ConfigureRole()
{
// Allow multiple simultaneous HTTP request threads
ServicePointManager.DefaultConnectionLimit = 12;
// Allow Azure Storage to always use the latest version of a config setting
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
if (!AzureRoleEnvironment.IsAvailable())
{
configSetter(ConfigurationManager.AppSettings[configName]);
return;
}
configSetter(AzureRoleEnvironment.GetConfigurationSettingValue(configName));
// Apply any changes to config when the config is edited http://msdn.microsoft.com/en-us/library/windowsazure/gg494982.aspx
AzureRoleEnvironment.Changed += (sender, arg) =>
{
if (!arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Any(change => (change.ConfigurationSettingName == configName)))
return;
if (!configSetter(AzureRoleEnvironment.GetConfigurationSettingValue(configName)))
AzureRoleEnvironment.RequestRecycle();
};
});
// Configure local resources
var localTempPath = GetLocalResourcePathAndSetAccess(TempLocalResource);
GetLocalResourcePathAndSetAccess(SitesLocalResource);
GetLocalResourcePathAndSetAccess(ExecutionLocalResource);
// WebDeploy creates temporary files during package creation. The default TEMP location allows for a 100MB
// quota (see http://msdn.microsoft.com/en-us/library/gg465400.aspx#Y976).
// For large web deploy packages, the synchronization process will raise an IO exception because the "disk is full"
// unless you ensure that the TEMP/TMP target directory has sufficient space
Environment.SetEnvironmentVariable("TMP", localTempPath);
Environment.SetEnvironmentVariable("TEMP", localTempPath);
}