ईवेंट्स
17 मार्च, 9 pm - 21 मार्च, 10 am
साथी डेवलपर्स और विशेषज्ञों के साथ वास्तविक दुनिया के उपयोग के मामलों के आधार पर स्केलेबल एआई समाधान बनाने के लिए मीटअप श्रृंखला में शामिल हों।
अभी पंजीकरण करेंयह ब्राउज़र अब समर्थित नहीं है.
नवीनतम सुविधाओं, सुरक्षा अपडेट और तकनीकी सहायता का लाभ लेने के लिए Microsoft Edge में अपग्रेड करें.
APPLIES TO:
NoSQL
This article explains how to convert between different session token formats to ensure compatibility between SDK versions.
नोट
By default, the SDK keeps track of the session token automatically and it will use the most recent session token. For more information, please visit Utilize session tokens. The instructions in this article only apply with the following conditions:
There are two session token formats: simple and vector. These two formats are not interchangeable so, the format should be converted when passing to the client application with different versions.
A simple session token has this format: {pkrangeid}:{globalLSN}
A vector session token has the following format:
{pkrangeid}:{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}
To pass a session token to client using .NET SDK V1, use a simple session token format. For example, use the following sample code to convert it.
private static readonly char[] SegmentSeparator = (new[] { '#' });
private static readonly char[] PkRangeSeparator = (new[] { ':' });
// sessionTokenToConvert = session token from previous response
string[] items = sessionTokenToConvert.Split(PkRangeSeparator, StringSplitOptions.RemoveEmptyEntries);
string[] sessionTokenSegments = items[1].Split(SessionTokenHelpers.SegmentSeparator, StringSplitOptions.RemoveEmptyEntries);
string sessionTokenInSimpleFormat;
if (sessionTokenSegments.Length == 1)
{
// returning the same token since it already has the correct format
sessionTokenInSimpleFormat = sessionTokenToConvert;
}
else
{
long version = 0;
long globalLSN = 0;
if (!long.TryParse(sessionTokenSegments[0], out version)
|| !long.TryParse(sessionTokenSegments[1], out globalLSN))
{
throw new ArgumentException("Invalid session token format", sessionTokenToConvert);
}
sessionTokenInSimpleFormat = string.Format("{0}:{1}", items[0], globalLSN);
}
To pass a session token to client using .NET SDK V2, use the vector session token format. For example, use the following sample code to convert it.
private static readonly char[] SegmentSeparator = (new[] { '#' });
private static readonly char[] PkRangeSeparator = (new[] { ':' });
// sessionTokenToConvert = session token from previous response
string[] items = sessionTokenToConvert.Split(PkRangeSeparator, StringSplitOptions.RemoveEmptyEntries);
string[] sessionTokenSegments = items[1].Split(SegmentSeparator, StringSplitOptions.RemoveEmptyEntries);
string sessionTokenInVectorFormat;
if (sessionTokenSegments.Length == 1)
{
long globalLSN = 0;
if (long.TryParse(sessionTokenSegments[0], out globalLSN))
{
sessionTokenInVectorFormat = string.Format("{0}:-2#{1}", items[0], globalLSN);
}
else
{
throw new ArgumentException("Invalid session token format", sessionTokenToConvert);
}
}
else
{
// returning the same token since it already has the correct format
sessionTokenInVectorFormat = sessionTokenToConvert;
}
Read the following articles:
ईवेंट्स
17 मार्च, 9 pm - 21 मार्च, 10 am
साथी डेवलपर्स और विशेषज्ञों के साथ वास्तविक दुनिया के उपयोग के मामलों के आधार पर स्केलेबल एआई समाधान बनाने के लिए मीटअप श्रृंखला में शामिल हों।
अभी पंजीकरण करेंप्रशिक्षण
प्रशिक्षण पथ
Conectar-se ao Azure Cosmos DB for NoSQL com o SDK - Training
Conectar-se ao Azure Cosmos DB for NoSQL com o SDK
Certification
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Escreva consultas eficientes, crie políticas de indexação, gerencie e provisione recursos na API e no SDK do SQL com o Microsoft Azure Cosmos DB.