Ejemplo n.º 1
0
        public async Task Initialize()
        {
            if (this.SheetsService != null)
            {
                return;
            }

            var kvClient          = new BasicKeyVaultClient();
            var googleBotClientId = await kvClient.GetSecretAsync("GoogleApiBotClientId");

            var googleBotPrivateKey = await kvClient.GetSecretAsync("GoogleApiPrivateKey");

            googleBotPrivateKey = googleBotPrivateKey.Replace("\\n", "\n");
            HeroicSheetsId      = await kvClient.GetSecretAsync("HeroicSignupsSheetId");

            var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(googleBotClientId)
            {
                Scopes = new[] { SheetsService.Scope.Spreadsheets }
            }.FromPrivateKey(googleBotPrivateKey));

            SheetsServiceSingleton = new SheetsService(
                new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "OMG Spiders Bot"
            });
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                var pw=new BasicKeyVaultClient().GetSecretAsync("DatabaseConnectionPassword").Result;

                optionsBuilder.UseSqlServer(
                    $"Server=tcp:omgspidersdb.database.windows.net,1433;Initial Catalog=omgspiders;" +
                    $"Persist Security Info=False;User ID=omgspiders;Password={pw};MultipleActiveResultSets=False;" +
                    $"Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
                    x => x.EnableRetryOnFailure(10, TimeSpan.FromSeconds(10), new[] { 40613, -2 }));
                
            }
        }