Skip to content

Commit 1cd8e2f

Browse files
author
David Watson
committed
Fix small issue in bicep templates for PEs, update app reg script to austomatically pull the app name from azd env
1 parent 59b587a commit 1cd8e2f

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

infra/private_endpoints_services.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ resource privateEndpointsDnsZoneGroup 'Microsoft.Network/privateEndpoints/privat
5555
properties: {
5656
privateDnsZoneConfigs: [
5757
{
58-
name: privateDnsZone.name
58+
name: dnsZoneName
5959
properties: {
60-
privateDnsZoneId: resourceId('Microsoft.Network/privateDnsZones', privateDnsZone.name)
60+
privateDnsZoneId: resourceId('Microsoft.Network/privateDnsZones', dnsZoneName)
6161
}
6262
}
6363
]

infra/resources.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ resource webApp 'Microsoft.Web/sites@2024-04-01' = {
253253
virtualNetworkSubnetId: usePrivateEndpoints ? privateEndpoints.outputs.appServiceSubnetId : null
254254
vnetRouteAllEnabled: usePrivateEndpoints ? false : null
255255
siteConfig: {
256-
linuxFxVersion: 'node|18-lts'
256+
linuxFxVersion: 'NODE|22-lts'
257257
alwaysOn: true
258258
appCommandLine: 'next start'
259259
ftpsState: 'Disabled'

scripts/appreg_setup.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ param (
66
)
77

88
if (-not $webappname) {
9+
$webappname=(azd env get-value AZURE_WEBAPP_NAME).Trim()
10+
}
11+
12+
if (-not $webappname -or $webappname -like "*ERROR*") {
913
Write-Host "`n Usage: .\appreg_setup.ps1 -webappname <webappname> [-showsecret] `n"
1014
Write-Host "No arguments provided. Please provide the web app name from the Azure portal (e.g. azurechat-ulg3yy5ybjhdq)."
1115
Write-Host "The -showsecret flag will display the client secret in the console output."

scripts/appreg_setup.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ while [[ "$#" -gt 0 ]]; do
1313
-showsecret)
1414
showsecret_flag="true"
1515
;;
16+
-localredirect)
17+
local_redirect_flag="true"
18+
;;
1619
*)
1720
echo "Unknown parameter passed: $1"
1821
exit 1
@@ -22,8 +25,13 @@ while [[ "$#" -gt 0 ]]; do
2225
done
2326

2427
if [[ -z "$webappname" ]]; then
28+
webappname=$(azd env get-value AZURE_WEBAPP_NAME)
29+
fi
30+
31+
if [[ -z "$webappname" ]] || [[ $webappname == *"ERROR"* ]]; then
32+
2533
echo ""
26-
echo "Usage: $0 -w <webappname> [-showsecret]"
34+
echo "Usage: $0 -w <webappname> [-showsecret] [-localredirect]"
2735
echo "No arguments provided. Please provide the web app name from the Azure portal (e.g. azurechat-ulg3yy5ybjhdq)."
2836
exit 1
2937
fi
@@ -51,8 +59,16 @@ echo "Done."
5159

5260
redirecturl="https://${webappname}.azurewebsites.net/api/auth/callback/azure-ad"
5361
graphurl="https://graph.microsoft.com/v1.0/applications/${objectid}"
54-
echo "> Updating redirect url to $redirecturl..."
55-
az rest --method PATCH --uri $graphurl --body "{'web':{'redirectUris':['${redirecturl}']}}"
62+
63+
if [[ "$local_redirect_flag" == "true" ]]; then
64+
echo "> Updating redirect url to $redirecturl and http://localhost:3000/api/auth/callback/azure-ad..."
65+
redirectBody="{'web':{'redirectUris':['${redirecturl}','http://localhost:3000/api/auth/callback/azure-ad']}}"
66+
else
67+
echo "> Updating redirect url to $redirecturl..."
68+
redirectBody="{'web':{'redirectUris':['${redirecturl}']}}"
69+
fi
70+
71+
az rest --method PATCH --uri $graphurl --body $redirectBody
5672
echo "Done."
5773

5874
rg=$(az webapp list --query "[?name=='${webappname}'].resourceGroup" --output tsv | tr -d '[:space:]')

0 commit comments

Comments
 (0)