Skip to content

Commit d809b70

Browse files
authored
disable AAD user operations on dev container environment (#151)
## Purpose This is a workaround for pipeline check ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [x] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [x] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Documentation content changes [ ] Other... Please describe: ```
1 parent ad3ae4d commit d809b70

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

.github/workflows/validation-sample-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616

1717
# https://github.com/microsoft/template-validation-action
18-
- uses: microsoft/[email protected].3
18+
- uses: microsoft/[email protected].5
1919
id: validation
2020
with:
2121
validateAzd: true

infra/bicep/hooks/postprovision.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,30 @@ GREEN='\033[0;32m'
1010
NC='\033[0m' # No Color
1111

1212
echo ""
13-
echo -e "${GREEN}INFO:${NC} Updating container apps connection ..."
14-
15-
# refresh service connection, via customers-service
16-
az containerapp connection create mysql-flexible --subscription $subscriptionId -g $resourceGroupName \
17-
--connection $sqlConnectName --source-id $customersServiceId --target-id $sqlDatabaseId --client-type springBoot \
18-
--user-identity client-id=$appUserIdentityClientId subs-id=$subscriptionId mysql-identity-id=$sqlAdminIdentityId \
19-
user-object-id=$AAD_USER_ID \
20-
-c $customersServiceName -y > /dev/null
21-
22-
# Allow user to visit Spring Boot Admin dashboard
23-
az role assignment create --role "Container Apps ManagedEnvironments Contributor" \
24-
--scope $containerAppsEnvironmentId \
25-
--assignee $AAD_USER_ID \
26-
--description "allow user to visit Spring Boot Admin dashboard" > /dev/null
13+
14+
# Skip AAD_USER_ID related operations in pipeline environment (CREATE_ROLE_FOR_USER == false)
15+
if [[ "$CREATE_ROLE_FOR_USER" == false ]]; then
16+
17+
echo -e "${GREEN}INFO:${NC} CREATE_ROLE_FOR_USER = false, missed AAD_USER_ID"
18+
echo -e "${GREEN}INFO:${NC} Should create service connection manually"
19+
20+
else
21+
22+
echo -e "${GREEN}INFO:${NC} Updating container apps connection ..."
23+
24+
# refresh service connection, via customers-service
25+
az containerapp connection create mysql-flexible --subscription $subscriptionId -g $resourceGroupName \
26+
--connection $sqlConnectName --source-id $customersServiceId --target-id $sqlDatabaseId --client-type springBoot \
27+
--user-identity client-id=$appUserIdentityClientId subs-id=$subscriptionId mysql-identity-id=$sqlAdminIdentityId \
28+
user-object-id=$AAD_USER_ID \
29+
-c $customersServiceName -y > /dev/null
30+
31+
# Allow user to visit Spring Boot Admin dashboard
32+
az role assignment create --role "Container Apps ManagedEnvironments Contributor" \
33+
--scope $containerAppsEnvironmentId \
34+
--assignee $AAD_USER_ID \
35+
--description "allow user to visit Spring Boot Admin dashboard" > /dev/null
36+
fi
2737

2838
echo ""
2939
echo -e "${GREEN}INFO:${NC} Deploy finish succeed!"

infra/bicep/hooks/preprovision.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ else
1111
exit 1
1212
fi
1313

14+
if [[ "$CREATE_ROLE_FOR_USER" == false ]]; then
15+
echo -e "${GREEN}INFO:${NC} CREATE_ROLE_FOR_USER = false, skipping AAD_USER_ID."
16+
exit 0
17+
fi
18+
1419
# Check input AAD User Id
1520
echo -e "${GREEN}INFO:${NC} Checking AAD_USER_ID: '$AAD_USER_ID'"
1621
if [[ $AAD_USER_ID =~ ^\{?[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}\}?$ ]]; then

0 commit comments

Comments
 (0)