@@ -83,6 +83,45 @@ else {
8383}
8484
8585$IMAGE_TAG = " latest"
86+ $DeploymentType = az group show `
87+ -- name $RESOURCE_GROUP `
88+ -- query " tags.Type" `
89+ - o tsv
90+ if ($DeploymentType -eq " WAF" ) {
91+
92+ Write-Host " "
93+ Write-Host " WAF deployment detected. Temporarily relaxing ACR restrictions..."
94+
95+ $acrAllowExport = az acr update `
96+ -- name $ACR_NAME `
97+ -- resource- group $RESOURCE_GROUP `
98+ -- allow- exports true
99+
100+ if ($LASTEXITCODE -ne 0 ) {
101+ throw " Failed to enable ACR exports."
102+ }
103+
104+ $acrPublicNetwork = az acr update `
105+ -- name $ACR_NAME `
106+ -- resource- group $RESOURCE_GROUP `
107+ -- public- network- enabled true
108+
109+ if ($LASTEXITCODE -ne 0 ) {
110+ throw " Failed to enable ACR public network access."
111+ }
112+
113+ $acrDefaultAction = az acr update `
114+ -- name $ACR_NAME `
115+ -- resource- group $RESOURCE_GROUP `
116+ -- default- action Allow
117+
118+ if ($LASTEXITCODE -ne 0 ) {
119+ throw " Failed to set ACR default action to Allow."
120+ }
121+
122+ Write-Host " ACR restrictions temporarily relaxed."
123+ }
124+
86125
87126# Get the script directory and navigate to repo root
88127$ScriptDir = $PSScriptRoot
@@ -95,6 +134,7 @@ Write-Host " Resource Group: $RESOURCE_GROUP"
95134Write-Host " Image Tag: $IMAGE_TAG "
96135Write-Host " "
97136
137+ try {
98138 # =============================================================================
99139 # Step 1: Build and push images to ACR using az acr build
100140 # =============================================================================
@@ -214,3 +254,29 @@ Write-Host ""
214254 Write-Host " ============================================================"
215255 Write-Host " ACR Build and Push - Completed Successfully!"
216256 Write-Host " ============================================================"
257+ }
258+ finally {
259+
260+ if ($DeploymentType -eq " WAF" ) {
261+
262+ Write-Host " "
263+ Write-Host " Restoring WAF ACR configuration..."
264+
265+ $acrDefaultAction = az acr update `
266+ -- name $ACR_NAME `
267+ -- resource- group $RESOURCE_GROUP `
268+ -- default- action Deny
269+
270+ $acrPublicNetwork = az acr update `
271+ -- name $ACR_NAME `
272+ -- resource- group $RESOURCE_GROUP `
273+ -- public- network- enabled false
274+
275+ $acrAllowExport = az acr update `
276+ -- name $ACR_NAME `
277+ -- resource- group $RESOURCE_GROUP `
278+ -- allow- exports false
279+
280+ Write-Host " ACR configuration restored."
281+ }
282+ }
0 commit comments