Beispiel #1
0
        public RawACIManager(IOptions <MyConfig> config, ILogger <RawACIManager> logger)
        {
            _config = config.Value;

            string token = AuthenticationHelpers.AcquireTokenBySPN(
                _config.TenantId, _config.ClientId, _config.ClientSecret).Result;

            _client = new HttpClient(new LoggingHandler(new HttpClientHandler(), logger));
            _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            _client.BaseAddress = new Uri("https://management.azure.com/");

//            CreateResourceGroup(_config.ResourceGroup).Wait();
        }
Beispiel #2
0
        public AppManager(IOptions <MyConfig> config, ILogger <AppManager> logger)
        {
            _config = config.Value;
            Logger  = logger;

            string token = AuthenticationHelpers.AcquireTokenBySPN(
                _config.TenantId, _config.ClientId, _config.ClientSecret).Result;

            _client = new HttpClient(new LoggingHandler(new HttpClientHandler(), logger));
            _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            _client.BaseAddress = new Uri("https://management.azure.com/");

            _allFreeApps.Add(Language.Node, new Queue <BaseApp>());
            _allFreeApps.Add(Language.Ruby, new Queue <BaseApp>());

            Init().Wait();

            CreateNewAppsIfNeeded().Wait();

            Logger.LogInformation("Setting up background timer");
            _timer = new Timer(_ => BackgroundMaintenance().Wait(), null, 0, 60000);
        }
Beispiel #3
0
        public ACIManager(IOptions <MyConfig> config, ILogger <ACIManager> logger)
        {
            _config = config.Value;
            Logger  = logger;

            _lock = new SemaphoreSlim(1, 1);
            _backgroundTaskLock        = new SemaphoreSlim(1, 1);
            _containerGroupCollections = new ConcurrentDictionary <string, ContainerGroupCollection>(StringComparer.OrdinalIgnoreCase);
            _appUsageTimes             = new ConcurrentDictionary <string, List <long> >(StringComparer.OrdinalIgnoreCase);

            string token = AuthenticationHelpers.AcquireTokenBySPN(
                _config.TenantId, _config.ClientId, _config.ClientSecret).Result;

            _client = new HttpClient(new LoggingHandler(new HttpClientHandler(), logger));
            _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
            _client.BaseAddress = new Uri("https://management.azure.com/");

            _functionsHttpClient = new HttpClient();

            LoadExistingApps().Wait();

            _timer = new Timer(async _ => await BackgroundMaintenance(), null, 0, 60000); // 60 seconds
        }