Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for Azure CosmosDB SQL API #85

Merged
merged 5 commits into from
Dec 8, 2023
Merged

Adding support for Azure CosmosDB SQL API #85

merged 5 commits into from
Dec 8, 2023

Conversation

pauldotyu
Copy link
Contributor

@pauldotyu pauldotyu commented Dec 7, 2023

Purpose

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code

Note: this requires you to have Go installed locally. If you do not have Go installed, open this repo using GitHub Codespaces.

git clone https://github.com/Azure-Samples/aks-store-demo
cd aks-store-demo
git checkout sql_api
  • Test the code against Azure CosmosDB MongoDB API

Create Azure CosmosDB instance

RGNAME=rg-cosmos<something_unique>
LOCNAME=<your_preferred_location>
COSMOSDBNAME=cosmos<something_unique>
PARTITIONKEY=storeId

az group create --name $RGNAME --location $LOCNAME
az cosmosdb create --name $COSMOSDBNAME --resource-group $RGNAME --kind GlobalDocumentDB
az cosmosdb sql database create --account-name $COSMOSDBNAME --name orderdb --resource-group $RGNAME
az cosmosdb sql container create --account-name $COSMOSDBNAME --database-name orderdb --name orders --resource-group $RGNAME --partition-key-path /$PARTITIONKEY

export ORDER_DB_API=cosmosdbsql
export ORDER_DB_URI=https://$COSMOSDBNAME.documents.azure.com:443/
export ORDER_DB_NAME=orderdb
export ORDER_DB_CONTAINER_NAME=orders
export ORDER_DB_PASSWORD=$(az cosmosdb keys list --name $COSMOSDBNAME --resource-group $RGNAME --query primaryMasterKey -o tsv)
export ORDER_DB_PARTITION_KEY=$PARTITIONKEY
export ORDER_DB_PARTITION_VALUE="pets"

Setup environment variables for local RabbitMQ

export ORDER_QUEUE_URI=amqp://localhost
export ORDER_QUEUE_USERNAME=username
export ORDER_QUEUE_PASSWORD=password
export ORDER_QUEUE_NAME=orders

Start the supporting containers

cd src/makeline-service
docker compose up -d --build

Start the makeline-service app

go get .
go run .

In VSCode, open the src/makeline-service/test-makeline-service.http file and test the HTTP methods to fetch, get, and update order documents.

What to Check

Verify that the following are valid

  • Open Azure portal, navigate to your Azure CosmosDB instance, open the data explorer, and ensure the documents are there.

Other Information

src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
@chzbrgr71 chzbrgr71 self-requested a review December 8, 2023 15:56
Copy link
Collaborator

@chzbrgr71 chzbrgr71 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and working as expected. I will merge. We can check this again using the official GHCR images once built

src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
src/makeline-service/mongodb.go Fixed Show fixed Hide fixed
@pauldotyu pauldotyu force-pushed the sql_api branch 2 times, most recently from bf7104c to 1fe09f0 Compare December 8, 2023 18:02
@pauldotyu pauldotyu force-pushed the sql_api branch 3 times, most recently from ef75d9f to 0a8d9d7 Compare December 8, 2023 18:35
@chzbrgr71 chzbrgr71 merged commit d32e32a into main Dec 8, 2023
4 checks passed
@pauldotyu pauldotyu deleted the sql_api branch December 19, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Azure CosmosDB SQL API
2 participants