Esempio n. 1
0
            public void ConfigureServices(IFunctionsHostBuilder builder, IConfiguration config)
            {
                _loggerFactory = new LoggerFactory();
                var logger = _loggerFactory.CreateLogger("Startup");

                if (Base._cache == null)
                {
                    Base._cache = new MemoryCache(new MemoryCacheOptions());
                }

                //Get Settings from KeyVault
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Cat")))
                {
                    Environment.SetEnvironmentVariable("SAS:Cat", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "cat").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Cont")))
                {
                    Environment.SetEnvironmentVariable("SAS:Cont", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "cont").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Icon")))
                {
                    Environment.SetEnvironmentVariable("SAS:Icon", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "icon").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Repo")))
                {
                    Environment.SetEnvironmentVariable("SAS:Repo", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "repo").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Wait")))
                {
                    Environment.SetEnvironmentVariable("SAS:Wait", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "wait").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Look")))
                {
                    Environment.SetEnvironmentVariable("SAS:Look", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "look").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Map")))
                {
                    Environment.SetEnvironmentVariable("SAS:Map", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "map").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Feedback")))
                {
                    Environment.SetEnvironmentVariable("SAS:Feedback", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "feedback").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Dlq")))
                {
                    Environment.SetEnvironmentVariable("SAS:Dlq", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "dlq").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Suq")))
                {
                    Environment.SetEnvironmentVariable("SAS:Suq", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "suq").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Faq")))
                {
                    Environment.SetEnvironmentVariable("SAS:Faq", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "faq").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Swq")))
                {
                    Environment.SetEnvironmentVariable("SAS:Swq", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "swq").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAS:Ip")))
                {
                    Environment.SetEnvironmentVariable("SAS:Ip", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "ip").Result.Value);
                }
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("sbConnection")))
                {
                    Environment.SetEnvironmentVariable("sbConnection", _keyVaultClient.GetSecretAsync(vaultBaseUrl: config["VaultUri"], secretName: "sbConnection").Result.Value);
                }

                var    binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string ResourcePath = Path.GetFullPath(Path.Combine(binDirectory, ".."));

                Console.WriteLine("loading RZ.Software-Providers:");
                Plugins.loadPlugins(Path.Combine(Path.Combine(ResourcePath, "wwwroot"), "plugins"));

                Console.Write("loading SW-Catalog...");
                Base.GetCatalog("", true);
                Console.WriteLine(" done.");

                RZ.ServerFN.IP2Location.Settings    = Plugins.dSettings;
                RZ.ServerFN.UpdateCounters.Settings = Plugins.dSettings;
                sbconnection = Environment.GetEnvironmentVariable("sbConnection");
            }