public CosmosContainer Convert(CosmosAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            ICosmosService service = configProvider.GetService(
                configProvider.ResolveConnectionString(attribute.ConnectionStringSetting),
                attribute.ApplicationName,
                attribute.ApplicationRegion);

            if (attribute.CreateIfNotExists)
            {
                var context = new CosmosContext
                {
                    ResolvedAttribute = attribute,
                    Service           = service
                };

                CosmosUtility.CreateDatabaseAndContainerNameIfNotExistAsync(context).Wait();
            }

            return(service.GetContainer(attribute.DatabaseName, attribute.ContainerName));
        }
Example #2
0
        public CosmosClient Convert(CosmosAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            ICosmosService service = configProvider.GetService(
                configProvider.ResolveConnectionString(attribute.ConnectionStringSetting),
                attribute.ApplicationName,
                attribute.ApplicationRegion);

            return(service.GetClient());
        }