Azure-Samples / aks-store-demo

Sample microservices app for AKS demos, tutorials, and experiments
MIT License
143 stars 225 forks source link

Adding support for Azure CosmosDB SQL API #85

Closed pauldotyu closed 9 months ago

pauldotyu commented 9 months ago

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

git clone https://github.com/Azure-Samples/aks-store-demo
cd aks-store-demo
git checkout sql_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

Other Information