azure - 移动应用:在 Xamarin.Forms 中使用“Microsoft.Azure.Cosmos”.NET SDK V3 - 跨平台
问题描述
我使用 Xamarin.Forms 创建了一个小型移动应用程序此应用程序使用 Cosmos DB(Azure 数据库)。我需要知道是否可以在 Xamarin.forms 中使用 Microsoft.Azure.Cosmos (Nuget)。如果可能的话,你能帮我弄清楚我做错了什么。
我使用了 Microsoft.Azure.DocumentDB.Core(v2.51) https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/)。这是在 azure-cosmos-dotnet-v2 下。一切正常。
今天,我正在尝试更新到 Microsoft.Azure.Cosmos (v3.10) https://www.nuget.org/packages/Microsoft.Azure.Cosmos/。这是在 azure-cosmos-dotnet-v3 下。但是一旦我点击 CreateItemAsync 行,系统就会失败。
CosmosClient client = new CosmosClient(CosmosEndpointUrl, CosmosAuthKey);
AccountProperties ap= await client.ReadAccountAsync(); // Check connection... It is OK
Database db = client.GetDatabase("MyDatabase");//My Database name is OK,
DatabaseResponse dbresponse= await db.ReadAsync();///Fail
Container container = client.GetContainer("MyDatabase", "MyCollection");
dynamic testItem = new { id = "1234", userId = "2222", details = "it's working" };
ItemResponse<dynamic> response = await container.CreateItemAsync<dynamic>(testItem); /// Fail...
[0:] DocDBTrace Error: 0 :
[0:] Operation will NOT be retried. Current attempt 0, Exception: System.NotSupportedException: Linked Away
at System.Runtime.Remoting.Messaging.CallContext.LogicalGetData (System.String ) [0x00005] in <4b124141b7914f4d8253001e6b8a15cf>:0
at System.Diagnostics.CorrelationManager.get_ActivityId () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.110/src/Xamarin.iOS/mcs/class/referencesource/System/compmod/system/diagnostics/CorrelationManager.cs:23
at Microsoft.Azure.Cosmos.ActivityScope..ctor (System.Guid activityId) [0x0000c] in <36733228c2e04bedaa8ccf505865c0ea>:0
at Microsoft.Azure.Cosmos.Routing.ClientCollectionCache.ReadCollectionAsync (System.String collectionLink, System.Threading.CancellationToken cancellationToken, Microsoft.Azure.Cosmos.IDocumentClientRetryPolicy retryPolicyInstance) [0x000b8] in <36733228c2e04bedaa8ccf505865c0ea>:0
at Microsoft.Azure.Documents.BackoffRetryUtility`1[T].ExecuteRetryAsync (System.Func`1[TResult] callbackMethod, System.Func`3[T1,T2,TResult] callShouldRetry, System.Func`1[TResult] inBackoffAlternateCallbackMethod, System.TimeSpan minBackoffForInBackoffCallback, System.Threading.CancellationToken cancellationToken, System.Action`1[T] preRetryCallback) [0x0008c] in <5ffe0b54a2fb4f58adef177e11a3d996>:0
**System.NotSupportedException:** 'Linked Away'
编辑:我添加了一些检查点,看起来连接正常(CosmosClient),但是数据库连接不正确。
解决方案
推荐阅读
- bash - 如果布尔值返回 true,则存储在数组中
- gtk3 - g_object_set_data 有内存漏洞
- ace-editor - 如何在单独的 div 中为多种语言设置 ace?
- oracle - JDeveloper 12C 和 ORACLE SOA SUITE 12C 中的 OSB 编辑器
- mysql - MySQL:我可以构建一个结合 SELECT 语句和硬编码列表的结果的 IN 子句吗?
- r - R中kdensity包中的自定义内核
- python - 如何每个月乘以一个值?
- python - Blender:python批处理/脚本将x3d格式转换为obj格式
- mongodb - 使用填充进行聚合
- javascript - 从热图中隐藏列