CosmosClient Konstruktoren
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Überlädt
CosmosClient() |
Erstellen eines neuen CosmosClients, der für Pseudotests verwendet wird |
CosmosClient(String, CosmosClientOptions) |
Erstellen eines neuen CosmosClient mit der Verbindungszeichenfolge CosmosClient ist threadsicher. Es wird empfohlen, eine einzelne instance von CosmosClient pro Lebensdauer der Anwendung beizubehalten, was eine effiziente Verbindungsverwaltung und -leistung ermöglicht. Weitere Informationen finden Sie im Leistungsleitfaden unter https://docs.microsoft.com/azure/cosmos-db/performance-tips. |
CosmosClient(String, String, CosmosClientOptions) |
Erstellen eines neuen CosmosClient mit der URI-Zeichenfolge des Kontoendpunkts und kontoschlüssels CosmosClient ist threadsicher. Es wird empfohlen, eine einzelne instance von CosmosClient pro Lebensdauer der Anwendung beizubehalten, was eine effiziente Verbindungsverwaltung und -leistung ermöglicht. Weitere Informationen finden Sie im Leistungsleitfaden unter https://docs.microsoft.com/azure/cosmos-db/performance-tips. |
CosmosClient()
Erstellen eines neuen CosmosClients, der für Pseudotests verwendet wird
protected CosmosClient ();
Protected Sub New ()
Gilt für:
CosmosClient(String, CosmosClientOptions)
Erstellen eines neuen CosmosClient mit der Verbindungszeichenfolge
CosmosClient ist threadsicher. Es wird empfohlen, eine einzelne instance von CosmosClient pro Lebensdauer der Anwendung beizubehalten, was eine effiziente Verbindungsverwaltung und -leistung ermöglicht. Weitere Informationen finden Sie im Leistungsleitfaden unter https://docs.microsoft.com/azure/cosmos-db/performance-tips.
public CosmosClient (string connectionString, Azure.Cosmos.CosmosClientOptions clientOptions = default);
new Azure.Cosmos.CosmosClient : string * Azure.Cosmos.CosmosClientOptions -> Azure.Cosmos.CosmosClient
Public Sub New (connectionString As String, Optional clientOptions As CosmosClientOptions = Nothing)
Parameter
- connectionString
- String
Die Verbindungszeichenfolge für das cosmos-Konto. beispiel: https://mycosmosaccount.documents.azure.com:443/; AccountKey=SuperSecretKey;
- clientOptions
- CosmosClientOptions
Clientoptionen (optional)
Beispiele
Der CosmosClient wird mit der Verbindungszeichenfolge erstellt und für die Verwendung der Region "USA, Osten 2" konfiguriert.
using Microsoft.Azure.Cosmos;
CosmosClient cosmosClient = new CosmosClient(
"account-endpoint-from-portal",
"account-key-from-portal",
new CosmosClientOptions()
{
ApplicationRegion = Regions.EastUS2,
});
// Dispose cosmosClient at application exit
Hinweise
https://docs.microsoft.com/azure/cosmos-db/performance-tips https://docs.microsoft.com/azure/cosmos-db/troubleshoot-dot-net-sdk
Gilt für:
CosmosClient(String, String, CosmosClientOptions)
Erstellen eines neuen CosmosClient mit der URI-Zeichenfolge des Kontoendpunkts und kontoschlüssels
CosmosClient ist threadsicher. Es wird empfohlen, eine einzelne instance von CosmosClient pro Lebensdauer der Anwendung beizubehalten, was eine effiziente Verbindungsverwaltung und -leistung ermöglicht. Weitere Informationen finden Sie im Leistungsleitfaden unter https://docs.microsoft.com/azure/cosmos-db/performance-tips.
public CosmosClient (string accountEndpoint, string authKeyOrResourceToken, Azure.Cosmos.CosmosClientOptions clientOptions = default);
new Azure.Cosmos.CosmosClient : string * string * Azure.Cosmos.CosmosClientOptions -> Azure.Cosmos.CosmosClient
Public Sub New (accountEndpoint As String, authKeyOrResourceToken As String, Optional clientOptions As CosmosClientOptions = Nothing)
Parameter
- accountEndpoint
- String
Der zu verwendende Cosmos-Dienstendpunkt
- authKeyOrResourceToken
- String
Der Cosmos-Kontoschlüssel oder das Ressourcentoken, das zum Erstellen des Clients verwendet werden soll.
- clientOptions
- CosmosClientOptions
Clientoptionen (optional)
Beispiele
Der CosmosClient wird mit der Region "AccountEndpoint", "AccountKey" oder "ResourceToken" erstellt und für die Verwendung der Region "USA, Osten 2" konfiguriert.
using Microsoft.Azure.Cosmos;
CosmosClient cosmosClient = new CosmosClient(
"account-endpoint-from-portal",
"account-key-from-portal",
new CosmosClientOptions()
{
ApplicationRegion = Regions.EastUS2,
});
// Dispose cosmosClient at application exit
Hinweise
https://docs.microsoft.com/azure/cosmos-db/performance-tips https://docs.microsoft.com/azure/cosmos-db/troubleshoot-dot-net-sdk
Gilt für:
Azure SDK for .NET