internal static IContainer BuildContainer()
        {
            var storageAccount         = CloudStorageAccount.Parse(AzureRoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
            var logFactory             = new NullLogFactory();
            const LoggerLevel logLevel = LoggerLevel.Off;

            var builder = new ContainerBuilder();

            Register(builder, storageAccount, logFactory, logLevel);
            builder.RegisterControllers(typeof(ContainerConfig).Assembly);
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            return(container);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public SyncService(IWebSiteRepository sitesRepository, ISyncStatusRepository syncStatusRepository, CloudStorageAccount storageAccount, string localSitesPath, string localTempPath, IEnumerable <string> directoriesToExclude, IEnumerable <string> sitesToExclude, Func <bool> syncEnabled, IISManager iisManager, ILoggerFactory loggerFactory, LoggerLevel logLevel)
        {
            _sitesRepository      = sitesRepository;
            _syncStatusRepository = syncStatusRepository;

            _localSitesPath       = localSitesPath;
            _localTempPath        = localTempPath;
            _directoriesToExclude = directoriesToExclude;
            _sitesToExclude       = sitesToExclude;
            _syncEnabled          = syncEnabled;
            _iisManager           = iisManager;
            _entries         = new Dictionary <string, FileEntry>();
            _siteDeployTimes = new Dictionary <string, DateTime>();
            _logger          = loggerFactory.Create(GetType(), logLevel);

            var sitesContainerName = AzureRoleEnvironment.GetConfigurationSettingValue(Constants.WebDeployPackagesBlobContainerKey).ToLowerInvariant();

            _container = storageAccount.CreateCloudBlobClient().GetContainerReference(sitesContainerName);
            _container.CreateIfNotExist();
        }