【发布时间】:2020-08-31 06:58:22
【问题描述】:
我正在尝试使用本地设置将新项目添加到 cosmos db 中。
这是我插入批量的代码:
private async Task AddSubscription(EnableOrDisableSubscriptionCommand command, SubscriptionAction subscriptionAction, IList<int> notificationCategoryTypes)
{
List<Task> bulkOperations = new List<Task>();
foreach (var notificationCategory in notificationCategoryTypes)
{
var notificationTypes = Utility.GetNotificationTypes((NotificationCategoryType)notificationCategory);
foreach (var notificationType in notificationTypes)
{
foreach (var payerAccountSubscriptions in command.Subscriptions)
{
if (payerAccountSubscriptions.AccountNumbers?.Any() ?? false)
{
foreach (var accountNumber in payerAccountSubscriptions.AccountNumbers.Where(a => !string.IsNullOrEmpty(a)))
{
bulkOperations.Add(_repository.Create(subscriptionAction, notificationType,
payerAccountSubscriptions.ColCoId, payerAccountSubscriptions.PayerNumber, accountNumber, command.UserRole,
command.UserId));
}
}
else
{
bulkOperations.Add(_repository.Create(subscriptionAction, notificationType,
payerAccountSubscriptions.ColCoId, payerAccountSubscriptions.PayerNumber, null, command.UserRole,
command.UserId));
}
}
}
}
await Task.WhenAll(bulkOperations);
}
public Task<ItemResponse<T>> CreateItemAsync(T item, string partitionKeyValue)
{
return _container.CreateItemAsync<T>(item, new PartitionKey(partitionKeyValue));
}
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
//localhost
"CosmosDbId": "Notifications",
"CosmoDbAuthKey": "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
"CosmoDbEndpoint": "https://localhost:8081/",
}
}
我已经安装了 Azure Cosmos DB 模拟器。
我收到以下未提供太多信息的错误?
[8/31/2020 6:49:10 AM] System.Private.CoreLib:出现异常 执行函数:EnableOrDisableSubscriptions。 Microsoft.Azure.Cosmos.Client:响应状态码未指示 成功:服务不可用(503);子状态:0;活动
【问题讨论】:
-
也可能是模拟器无法初始化网络堆栈。检查您是否安装了 Pulse 安全客户端或瞻博网络客户端,因为它们的网络过滤器驱动程序可能会导致问题。卸载第三方网络过滤器驱动程序通常可以解决此问题。或者,使用 /DisableRIO 启动模拟器,这会将模拟器网络通信切换到常规 Winsock。
-
你能显示异常的完整堆栈跟踪吗?
-
卸载 Azure Cosmos DB 模拟器旧版本并安装新版本 2.11.2 时问题得到解决。
标签: azure-cosmosdb azure-cosmosdb-sqlapi