I have been getting the error below since following this Azure DocumentDB guide which causes the analytics and other xDB functionally not to work (an example being Experience Analytics graphs not loading due to an error).
I am using the new Cosmos DB with MongoDB API for xDB along with using Sitecore 8.1 Update 1 which I suspect could be part of the problem as 8.1 supports up to version 3.0 of Mongo and Cosmos might be using a newer version. The actual connection appears to be fine since I am getting no TLS related access errors and all the collections were made as soon as I updated my connection strings although I have virtually no actual documents in any of the xDB databases. However, since I have not done as much work with xDB in the past I'm unsure if this is compatibly issue vs something that I haven't configured.
Exception: System.InvalidCastException Message: Unable to cast object of type 'MongoDB.Bson.BsonInt32' to type 'MongoDB.Bson.BsonInt64'. Source: Sitecore.Analytics.MongoDB at Sitecore.Analytics.RangeScheduler.MongoDbRangeMap2.BuildRangeRecord(BsonDocument document) at Sitecore.Analytics.RangeScheduler.MongoDbRangeMap2.TryLockRange(WorkerHandle worker, DateTime leaseExpiration, RangeHandle& range) at Sitecore.Analytics.Processing.RangeScheduler.RangeMapWorkScheduler3`1.TryLockRange(WorkScheduler`1& context) at Sitecore.Analytics.Processing.RangeScheduler.RangeMapWorkScheduler3`1.GetNextRange(WorkScheduler`1& context, Boolean returning) at Sitecore.Analytics.Processing.RangeScheduler.RangeMapWorkScheduler3`1.TryGetNext(ItemBatch`1& item) at Sitecore.Analytics.Processing.WorkSchedulerWithBacklog`1.TryGetNext(ItemBatch`1& batch) at Sitecore.Analytics.Aggregation.Data.Processing.InteractionBatchHistoryWorker.Execute() at Sitecore.Analytics.Core.BackgroundService.Run()