public static async Task <DocumentServiceLeaseStoreManager> InitializeAsync(
            ContainerInternal leaseContainer,
            string leaseContainerPrefix,
            string instanceName)
        {
            ContainerResponse cosmosContainerResponse = await leaseContainer.ReadContainerAsync().ConfigureAwait(false);

            ContainerProperties containerProperties = cosmosContainerResponse.Resource;

            bool isPartitioned =
                containerProperties.PartitionKey != null &&
                containerProperties.PartitionKey.Paths != null &&
                containerProperties.PartitionKey.Paths.Count > 0;
            bool isMigratedFixed = containerProperties.PartitionKey?.IsSystemKey == true;

            if (isPartitioned &&
                !isMigratedFixed &&
                (containerProperties.PartitionKey.Paths.Count != 1 || containerProperties.PartitionKey.Paths[0] != "/id"))
            {
                throw new ArgumentException("The lease collection, if partitioned, must have partition key equal to id.");
            }

            RequestOptionsFactory requestOptionsFactory = isPartitioned && !isMigratedFixed ?
                                                          (RequestOptionsFactory) new PartitionedByIdCollectionRequestOptionsFactory() :
                                                          (RequestOptionsFactory) new SinglePartitionRequestOptionsFactory();

            DocumentServiceLeaseStoreManagerBuilder leaseStoreManagerBuilder = new DocumentServiceLeaseStoreManagerBuilder()
                                                                               .WithLeasePrefix(leaseContainerPrefix)
                                                                               .WithLeaseContainer(leaseContainer)
                                                                               .WithRequestOptionsFactory(requestOptionsFactory)
                                                                               .WithHostName(instanceName);

            return(await leaseStoreManagerBuilder.BuildAsync().ConfigureAwait(false));
        }