I created a small mobile app using Xamarin.Forms This app use Cosmos DB (Azure Database). I need to know if it is possible to use Microsoft.Azure.Cosmos (Nuget) in Xamarin.forms. If it is possible, can you help me to figure out what I am doing wrong.
I used the Microsoft.Azure.DocumentDB.Core(v2.51) https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/). This is under azure-cosmos-dotnet-v2. Everything works OK.
Today, I am trying to update to Microsoft.Azure.Cosmos (v3.10) https://www.nuget.org/packages/Microsoft.Azure.Cosmos/. This is under azure-cosmos-dotnet-v3. But as soon i hit the line CreateItemAsync, the system fail.
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'
EDIT: I add some checkpoint, and looks like the connection is OK (CosmosClient), however the database is not connected properly.