宇航员 (Cosmos DB) - 输入不是有效的 Base-64 字符串

Cosmonaut (Cosmos DB) - The input is not a valid Base-64 string

我尝试编写通用的 cosmos Db classes,当在 Cosmonaut,CosmosDb 包装器的帮助下有很多集合时,这将很有帮助。这里是 Factory class

的例子
 public class CosmosDbClientFactory: ICosmosDbClientFactory
{
    private readonly string _databaseName;
    private readonly string _endpointUrl;
    private readonly string _masterKey;

    public CosmosDbClientFactory(string databaseName, string endpointUrl, string masterKey)
    {
        _databaseName = databaseName ?? throw new ArgumentNullException(nameof(databaseName));
        _endpointUrl = endpointUrl ?? throw new ArgumentNullException(nameof(endpointUrl));
        _masterKey = masterKey ?? throw new ArgumentNullException(nameof(masterKey));
    }

    public CosmosStoreSettings GetCosmosStoreSettings()
    {
        var cosmosStoreSettings = new CosmosStoreSettings(
            databaseName: _databaseName,
            endpointUrl: _endpointUrl,
            authKey: _masterKey );
        return cosmosStoreSettings;
    } 

我有我的存储库class,它是

public abstract class CosmosDbRepository<T> where T: Entity
{
    private readonly ICosmosDbClientFactory _cosmosDbClientFactory;

    protected CosmosDbRepository(ICosmosDbClientFactory cosmosDbClientFactory)
    {
        _cosmosDbClientFactory = cosmosDbClientFactory;
    }

    public Task<string> AddAsync(T entity)
    {
        try
        {
            entity.Id = GenerateId(entity);
            ICosmosStore<T> cosmosStore = new CosmosStore<T>(_cosmosDbClientFactory.GetCosmosStoreSettings());
            var response = cosmosStore.AddAsync(entity);
            return Task.FromResult(entity.Id);
        }
        catch (Exception e)
        {
            Debug.WriteLine("Failed to save data into CosmosDb");
            throw;
        }
    } 
}

当我尝试使用该存储库时,出现以下错误

"The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."

来自行

 ICosmosStore<T> cosmosStore = new CosmosStore<T>(_cosmosDbClientFactory.GetCosmosStoreSettings());

请问有没有人能帮我看看是什么原因?

根据评论,问题的根源是提供的 _masterKey 不是有效的 Base 64 字符串,也不是有效的 Cosmos DB 密钥。