Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
NoSQL
Sample solutions that do CRUD operations and other common operations on Azure Cosmos DB resources are included in the azure-documentdb-go GitHub repository. This article provides:
- Links to the tasks in each of the Go example project files.
- Links to the related API reference content.
- Within an Azure active subscription:
- Create an Azure Account or use your existing subscription
- Visual Studio Monthly Credits
- Azure Cosmos DB
- go installed on your computer, and a working knowledge of Go.
- Visual Studio Code.
- The Go extension for Visual Studio Code.
- Git.
- Azure Cosmos DB for NoSQL SDK for Go
To learn about the Azure Cosmos DB databases before running the following samples, see Working with databases, containers, and items conceptual article.
Task | API reference |
---|---|
Create a database | Client.CreateDatabase |
Read a database by ID | Client.NewDatabase |
Delete a database | DatabaseClient.Delete |
To learn about the Azure Cosmos DB collections before running the following samples, see Working with databases, containers, and items conceptual article.
Task | API reference |
---|---|
Create a container | DatabaseClient.CreateContainer |
Get a container by its ID | DatabaseClient.NewContainer |
Delete a container | ContainerClient.Delete |
The cosmos_container.go Go sample shows how to do the following tasks. To learn about the Azure Cosmos DB documents before running the following samples, see Working with databases, containers, and items conceptual article.
Task | API reference |
---|---|
Create a item in a container | ContainerClient.CreateItem |
Read an item by its ID | ContainerClient.ReadItem |
Query items | ContainerClient.NewQueryItemsPager |
Replace an item | ContainerClient.ReplaceItem |
Upsert an item | ContainerClient.UpsertIitem |
Delete an item | ContainerClient.DeleteItem |
Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
- If all you know is the number of vcores and servers in your existing database cluster, read about estimating request units using vCores or vCPUs
- If you know typical request rates for your current database workload, read about estimating request units using Azure Cosmos DB capacity planner