page_type | languages | products | description | ||||
---|---|---|---|---|---|---|---|
sample |
|
|
This sample shows you how to optimize throughput when importing data to Azure Cosmos DB through the SQL API using bulk support on .NET SDK |
This sample shows you how to optimize throughput when importing data to Azure Cosmos DB through the SQL API using bulk support on .NET SDK.
For a complete end-to-end walkthrough, please refer to the full tutorial on the Azure Cosmos DB documentation page.
-
Before you can run this sample, you must have the following prerequisites:
- An active Azure Cosmos DB account - If you don't have an account, refer to the Create a database account article. Optionally, you can use the Azure Cosmos DB Emulator.
- NET Core SDK 3+.
-
Clone this repository, or download the zip file.
-
Browse to the
src
folder. -
Run
dotnet build
to restore all packages. -
Retrieve the URI and PRIMARY KEY (or SECONDARY KEY) values from the Keys blade of your Azure Cosmos DB account in the Azure portal. For more information on obtaining endpoint & keys for your Azure Cosmos DB account refer to View, copy, and regenerate access keys and passwords. If you are using the Emulator, you can also use its credentials.
-
In the Program.cs file, located in the
src
directory, find EndPointUri and AuthorizationKey and replace the placeholder values with the values obtained for your account.
private const string EndpointUrl = "https://<your-account>.documents.azure.com:443/";
private const string AuthorizationKey = "<your-account-key>";
- You can now run the application with
dotnet run
.
The code included in this sample is intended to show you how to leverage the bulk support to optimize throughput when you import data to Azure Cosmos DB.
- Azure Cosmos DB Documentation
- Azure Cosmos DB .NET SDK for SQL API
- Azure Cosmos DB .NET SDK Reference Documentation
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.