Skip to content

Commit b46c362

Browse files
committed
Updates preprovision script to run on windows or posix
1 parent 18cc204 commit b46c362

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

azure.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ infra:
1414
bicep: ./infra/main.bicep
1515
hooks:
1616
preprovision:
17-
shell: pwsh
18-
continueOnError: false
19-
interactive: true
20-
run: ./infra/azd-hooks/preprovision.ps1
17+
posix:
18+
shell: sh
19+
continueOnError: false
20+
interactive: false
21+
run: ./infra/azd-hooks/preprovision.sh
22+
windows:
23+
shell: pwsh
24+
continueOnError: false
25+
interactive: false
26+
run: ./infra/azd-hooks/preprovision.ps1

infra/azd-hooks/preprovision.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
echo "Running preprovision.sh..."
4+
5+
# Get the user principal name of the signed-in user and write it to the .env file for the azd environment
6+
echo "Fetching User Principal Name and setting PRINCIPAL_NAME environment variable..."
7+
PRINCIPAL_NAME=$(az ad signed-in-user show --query 'userPrincipalName' -o tsv)
8+
azd env set "PRINCIPAL_NAME" "$PRINCIPAL_NAME"
9+
echo "PRINCIPAL_NAME: $PRINCIPAL_NAME"
10+
11+
# Get the client IP address and write it to the .env file for the azd environment
12+
echo "Fetching Client IP address and setting CLIENT_IP_ADDRESS environment variable..."
13+
CLIENT_IP_ADDRESS=$(curl -s https://api.ipify.org)
14+
azd env set "CLIENT_IP_ADDRESS" "$CLIENT_IP_ADDRESS"
15+
echo "CLIENT_IP_ADDRESS: $CLIENT_IP_ADDRESS"

0 commit comments

Comments
 (0)