Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f51bdee
Add HOME so the script can be run in any folder
petetian Mar 7, 2025
4891990
Merge branch 'Azure-Samples:main' into main
petetian Mar 7, 2025
74c3136
Updated azure-resource.profile and create-azure-resource.sh with new …
petetian Mar 7, 2025
8d42816
Add bash scripts for lab-2
petetian Mar 8, 2025
b406e13
add create.mysql.sh
petetian Mar 9, 2025
6212a30
Remove the dependencies of external parameters
petetian Mar 9, 2025
6aeeeba
new module creation
petetian Mar 9, 2025
c2fe648
create new module
petetian Mar 9, 2025
3249751
Remove unused variable
petetian Mar 10, 2025
29df268
Update azd json with steps in lab2
petetian Mar 10, 2025
fa60784
create docker images for microservices
petetian Mar 10, 2025
7afe183
refactory
petetian Mar 11, 2025
5cf4a91
Refactory
petetian Mar 11, 2025
ae3fac9
Refactor: move azure-resource.profile to ../config sharing with other…
petetian Mar 11, 2025
4f8ab79
Refactor: source the config file created by the previous step. Add ap…
petetian Mar 11, 2025
188d693
Refactor
petetian Mar 11, 2025
94ff0ef
Refactor: use common config file
petetian Mar 11, 2025
27b345a
Write created components to config file
petetian Mar 12, 2025
766ca0a
add new module
petetian Mar 12, 2025
901cf04
update .gitignore
petetian Mar 12, 2025
1dfd416
update .gitignore
petetian Mar 12, 2025
87d939a
export LOCATION
petetian Mar 12, 2025
7e2780b
add lab-3
petetian Mar 13, 2025
d923a1d
Merge remote-tracking branch 'upstream'
petetian Mar 13, 2025
dc6a7ed
create main script as entry point
petetian Mar 13, 2025
058f350
add script for lab 3
petetian Mar 13, 2025
f575923
add lab-3; refactor lab-2
petetian Mar 13, 2025
b210c9f
bug fixing
petetian Mar 13, 2025
fa209e0
bug fixing
petetian Mar 13, 2025
a71b2a3
bug fixing
petetian Mar 13, 2025
678f85a
clean up
petetian Mar 13, 2025
5c65673
clean up
petetian Mar 13, 2025
7366333
create lab-3
petetian Mar 14, 2025
293b48b
bug fixing
petetian Mar 15, 2025
77c96eb
add java modules
petetian Mar 18, 2025
d2b4001
fix bugs in Java modules
petetian Mar 18, 2025
9e43a81
lab-3 fully working version
petetian Mar 18, 2025
77e68cb
add main script for lab-3
petetian Mar 18, 2025
6b03acf
update chat joke url
petetian Mar 18, 2025
55f730d
create scripts in lab-4
petetian Mar 19, 2025
710a35b
more for lab-4
petetian Mar 19, 2025
b891f6f
merge from upstream
petetian Apr 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/azure-resource.profile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# Set all the variables with <> and keep the others unchanged

# This part is for lab 2 & Lab 3

# Pay attention to this, use command 'openssl rand -hex 3' to generate a unique id and put value here, don't put command here
UNIQUEID=<unique-id>

# To extract the subscription ID, use the following Azure CLI command:
# az account show --query id --output tsv
SUBSCRIPTION=<subscription-id>
LOCATION=<region>

APPNAME=petclinic
RESOURCE_GROUP=rg-$APPNAME-$UNIQUEID
Expand Down
28 changes: 13 additions & 15 deletions tools/create-azure-resource.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
#!/usr/bin/env bash

source ./azure-resource.profile
source ./funcs.sh
export HOME=/workspaces/java-on-aca

source ./tools/azure-resource.profile
source ./tools/funcs.sh

# Resource Group

# Random regions for MySQL server
LOCATION=$(random_element australiaeast brazilsouth eastasia eastus2 japaneast southindia swedencentral westus)
Copy link
Collaborator

@sonwan2020 sonwan2020 Mar 10, 2025

Choose a reason for hiding this comment

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

Here are the problems with these regions:

  1. OpenAI not supported in eastasia
  2. Managed Grafana not supported in southindia, prefer use centralindia
    See the differences between AI_LOCATION, SQL_LOCATION, GRAFANA_LOCATION

Copy link
Collaborator

@sonwan2020 sonwan2020 Mar 10, 2025

Choose a reason for hiding this comment

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

BTW, I don't think the potential regional latency is matter in this lab environment


az group create -g $RESOURCE_GROUP -l $LOCATION -o table

az configure --default group=$RESOURCE_GROUP

# MySQL server

# Random regions for MySQL server
SQL_LOCATION=$(random_element australiaeast brazilsouth eastasia eastus2 japaneast southindia swedencentral westus)

SQL_ID=$(az mysql flexible-server show --resource-group $RESOURCE_GROUP --name $MYSQL_SERVER_NAME -o tsv --query id 2>/dev/null)
if [[ -n $SQL_ID ]]; then
echo -e "${GREEN}INFO:${NC} MySQL server $MYSQL_SERVER_NAME already exists"
else
echo -e "${YELLOW}INFO:${NC} Creating MySQL server $MYSQL_SERVER_NAME in region $SQL_LOCATION ..."
echo -e "${YELLOW}INFO:${NC} Creating MySQL server $MYSQL_SERVER_NAME in region $LOCATION ..."

az mysql flexible-server create \
--admin-user $MYSQL_ADMIN_USERNAME \
--admin-password $MYSQL_ADMIN_PASSWORD \
--name $MYSQL_SERVER_NAME \
--resource-group $RESOURCE_GROUP \
--location $SQL_LOCATION \
--location $LOCATION \
--public-access none \
--yes \
--output table
Expand All @@ -49,18 +51,16 @@ fi

# Azure OpenAI Service

AI_LOCATION=$(random_element australiaeast brazilsouth eastus2 japaneast southindia swedencentral westus)

AI_ID=$(az cognitiveservices account show --resource-group $RESOURCE_GROUP --name $OPEN_AI_SERVICE_NAME -o tsv --query id 2>/dev/null)
if [[ -n $ACR_ID ]]; then
echo -e "${GREEN}INFO:${NC} OpenAI instance $OPEN_AI_SERVICE_NAME already exists"
else
echo -e "${YELLOW}INFO:${NC} Creating OpenAI instance $OPEN_AI_SERVICE_NAME in region $AI_LOCATION ..."
echo -e "${YELLOW}INFO:${NC} Creating OpenAI instance $OPEN_AI_SERVICE_NAME in region $LOCATION ..."

az cognitiveservices account create \
--resource-group $RESOURCE_GROUP \
--name $OPEN_AI_SERVICE_NAME \
--location $AI_LOCATION \
--location $LOCATION \
--kind OpenAI \
--sku s0 \
--custom-domain $OPEN_AI_SERVICE_NAME \
Expand Down Expand Up @@ -122,18 +122,16 @@ fi

# Azure Managed Grafana

GRAFANA_LOCATION=$(random_element australiaeast brazilsouth centralindia eastasia eastus2 japaneast swedencentral westus)

GRAFANA_ID=$(az grafana show --name $GRAFANA_NAME --resource-group $RESOURCE_GROUP -o tsv --query id 2>/dev/null)
if [[ -n $GRAFANA_ID ]]; then
echo -e "${GREEN}INFO:${NC} Grafana instance $GRAFANA_NAME already exists"
else
echo -e "${YELLOW}INFO:${NC} Creating Grafana instance $GRAFANA_NAME in region $GRAFANA_LOCATION ..."
echo -e "${YELLOW}INFO:${NC} Creating Grafana instance $GRAFANA_NAME in region $LOCATION ..."

az deployment group create \
--resource-group $RESOURCE_GROUP \
--template-file ../infra/bicep/modules/grafana/grafana-dashboard.bicep \
--parameters grafanaName=$GRAFANA_NAME location=$GRAFANA_LOCATION \
--parameters grafanaName=$GRAFANA_NAME location=$LOCATION \
--output table
fi

Expand Down