Using CosmosDB as a key-value store with Golang

Viewed 64

I'm trying to figure out the best way to use a key-value store from Golang in a Microsoft Azure environment and understand that CosmosDB can provide that, but I'm a little confused on how to best consume that. One thing that I'd really like is the ability to set a TTL on entities I insert into my table.

I see that CosmosDB has the Tables API, however I the only Golang package I see that would let me interface with that is the package intended to be used with Azure Table Storage, and there's no way to programmatically set the TTL in that case, correct?

I believe that both the SQL API and Mongo API can provide me with a document database. Is that correct? Would that be suitable to use as a k/v store with reasonably quick lookup times?

Thanks

1 Answers

Following on Mark's response, please use the Cosmos DB Go SDK: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/data/azcosmos

It currently supports:

  • Authentication by master key and RBAC/MSI/AAD
  • Point operations (covers your k-v needs)
  • TransactionalBatch
  • Query on single partition

The Go page contains the examples and usage documentation of the package.

Related