public PostItemRepository()
        {
            var config = AppConfig.Instance;

            _db            = new DocumentDbDataSource(config.DocDbEndpointUri, config.DocDbPrimaryKey);
            dbName         = config.DocDbDatabaseName;
            collectionName = config.DocDbCollectionNameForPosts;

            ValidateDbAndCollectionExists(dbName, collectionName);
        }
        private static IConfigurationProvider CreateConfigurationProvider(IServiceProvider services)
        {
            var serviceContext = services.GetRequiredService <ServiceContext>();
            var configSection  = serviceContext.CodePackageActivationContext.GetConfigurationPackageObject("Config").Settings.Sections["ConfigurationConnection"];
            var connectionInfo = new DocumentDbConnectionInfo
            {
                DatabaseName = configSection.Parameters["DatabaseName"].Value,
                Key          = configSection.Parameters["Key"].Value,
                Uri          = new Uri(configSection.Parameters["Uri"].Value)
            };

            var dataSource = new DocumentDbDataSource("ConfigurationDataSource", connectionInfo);

            return(new DataSourceBackedConfigurationProvider(dataSource, services.GetRequiredService <ITransactionManager>()));
        }
        public AuthenticationService(StatelessServiceContext context)
            : base(context)
        {
            var configSection  = context.CodePackageActivationContext.GetConfigurationPackageObject("Config").Settings.Sections["ConfigurationConnection"];
            var connectionInfo = new DocumentDbConnectionInfo
            {
                DatabaseName = configSection.Parameters["DatabaseName"].Value,
                Key          = configSection.Parameters["Key"].Value,
                Uri          = new Uri(configSection.Parameters["Uri"].Value)
            };

            var dbDataSource = new DocumentDbDataSource("Database", connectionInfo);

            _userRepository = new DataSourceRepository <UserAuthenticationInfo>
                                  (dbDataSource, "UserAuthenticationInfos");
        }