Skip to content

Commit a1e14c5

Browse files
authored
Simplify infrastructure deployment with Bicep parameters and rename global resource group (#793)
### Summary & Motivation Replace inline Bicep parameter strings with structured .bicepparam files to simplify deployment scripts and improve maintainability. This eliminates manual parameter string construction and makes parameter management cleaner. - Add main-cluster.bicepparam file that reads all parameters from environment variables - Update deploy-cluster.sh to use `bicep build-params` command - Export all variables instead of constructing inline parameter strings - Rename global resource group from `pxp-stage` to `pxp-stage-global` to clarify these are globally shared resources - Rename all resource group variables to explicitly distinguish `CLUSTER_RESOURCE_GROUP_NAME` vs `GLOBAL_RESOURCE_GROUP_NAME` - Generate revision suffix in shell script using random hex to avoid Bicep newGuid() what-if validation limitations - Upgrade all Bicep modules to latest stable API versions - Remove unsupported softDeletePolicy from Container Registry - Suppress false positive BCP318 warnings in role assignment modules - Display DNS configuration instructions during Plan phase - Fix spelling errors in appGateway module name and issue templates - Fix bug from previous change where database migration comments were deleted across different self-contained systems ### Downstream projects 1. **Create new global resource group and move resources** The global resource group has been renamed from `{uniquePrefix}-{environment}` to `{uniquePrefix}-{environment}-global` (e.g., `ppdemo-stage` → `ppdemo-stage-global`) for better clarity. Resources keep their original names (e.g., `ppdemo-stage`). - Create the new resource group `{uniquePrefix}-{environment}-global` in Azure Portal - Move these 5 resources using "Move to another resource group": - Azure Container Registry (e.g., `ppdemostage`) - Application Insights (e.g., `ppdemo-stage`) - Log Analytics workspace (e.g., `ppdemo-stage`) - Application Insights Smart Detection (action group) - Smart detector alert rule (e.g., `ppdemo-stage-failure-anomalies`) 2. **Update self-contained system version exports** In `cloud-infrastructure/cluster/deploy-cluster.sh`, update the resource group variable name in your self-contained system version export (all downstream projects have at least one self-contained system beyond Account Management and Back Office): ```diff -export YOUR_SELF_CONTAINED_SYSTEM_VERSION=$(get_active_version "your-self-contained-system-api" $RESOURCE_GROUP_NAME) +export YOUR_SELF_CONTAINED_SYSTEM_VERSION=$(get_active_version "your-self-contained-system-api" $CLUSTER_RESOURCE_GROUP_NAME) ``` 3. **Add revisionSuffix parameter to container app modules** In `cloud-infrastructure/cluster/main-cluster.bicep`, add the `revisionSuffix` parameter to your self-contained system container app modules: ```diff userAssignedIdentityName: yourSelfContainedSystemIdentityName ingress: true + revisionSuffix: revisionSuffix environmentVariables: yourSelfContainedSystemEnvironmentVariables ``` 4. **(Optional) Migrate custom API keys and secrets to bicepparam** Only needed if you have custom API keys, client secrets, or service configurations beyond standard PlatformPlatform. In `cloud-infrastructure/cluster/deploy-cluster.sh`, ensure custom secrets are exported: ```diff +export YOUR_CUSTOM_API_KEY +export YOUR_CUSTOM_CLIENT_SECRET ``` In `cloud-infrastructure/cluster/main-cluster.bicepparam`, add entries for custom parameters that were in the inline DEPLOYMENT_PARAMETERS string: ```diff +param yourCustomApiKey = readEnvironmentVariable('YOUR_CUSTOM_API_KEY') +param yourCustomClientSecret = readEnvironmentVariable('YOUR_CUSTOM_CLIENT_SECRET') ``` ### Checklist - [x] I have added tests, or done manual regression tests - [x] I have updated the documentation, if necessary
2 parents bb99bb8 + 6e2476e commit a1e14c5

30 files changed

+241
-202
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
4-
url: https://github.com/platform/platform/discussions/new/choose
4+
url: https://github.com/platformplatform/PlatformPlatform/discussions/new/choose
55
about: Start a new discussion on our GitHub Community pages
6-
- name: Browse exisitng discussions
7-
url: https://github.com/platform/platform/discussions
6+
- name: Browse existing discussions
7+
url: https://github.com/platformplatform/PlatformPlatform/discussions
88
about: Visit our GitHub Community pages to view existing discussions (or click Discussions in the menu)

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ body:
66
- type: markdown
77
attributes:
88
value: |
9-
Thanks for taking the time to fill out this bug report!
9+
Thanks for taking the time to fill out this feature request!
1010
- type: input
1111
id: contact
1212
attributes:
@@ -19,7 +19,7 @@ body:
1919
id: detailed-description
2020
attributes:
2121
label: Detailed description?
22-
description: Also tell us more about the bug, and what you were expecting.
22+
description: Tell us more about the feature request and what you would like to see.
2323
value: |
2424
**Is your feature request related to a problem? Please describe.**
2525
A clear and concise description of what the problem is.

.github/workflows/_deploy-container.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ jobs:
100100
101101
- name: Deploy Container
102102
run: |
103+
CLUSTER_RESOURCE_GROUP_NAME="${{ env.UNIQUE_PREFIX }}-${{ env.ENVIRONMENT }}-${{ env.CLUSTER_LOCATION_ACRONYM }}"
103104
SUFFIX=$(echo "${{ inputs.version }}" | sed 's/\./-/g')
104-
az containerapp update --name ${{ inputs.image_name }} --resource-group "${{ env.UNIQUE_PREFIX }}-${{ env.ENVIRONMENT }}-${{ env.CLUSTER_LOCATION_ACRONYM }}" --image "${{ env.UNIQUE_PREFIX }}${{ env.ENVIRONMENT }}.azurecr.io/${{ inputs.image_name }}:${{ inputs.version }}" --revision-suffix $SUFFIX
105+
az containerapp update --name ${{ inputs.image_name }} --resource-group "$CLUSTER_RESOURCE_GROUP_NAME" --image "${{ env.UNIQUE_PREFIX }}${{ env.ENVIRONMENT }}.azurecr.io/${{ inputs.image_name }}:${{ inputs.version }}" --revision-suffix $SUFFIX
105106
106107
echo "Waiting for the new revision to be active..."
107108
for i in {1..10}; do
108109
sleep 15
109110
110-
RUNNING_STATUS=$(az containerapp revision list --name ${{ inputs.image_name }} --resource-group "${{ env.UNIQUE_PREFIX }}-${{ env.ENVIRONMENT }}-${{ env.CLUSTER_LOCATION_ACRONYM }}" --query "[?contains(name, '$SUFFIX')].properties.runningState" --output tsv)
111-
HEALTH_STATUS=$(az containerapp revision list --name ${{ inputs.image_name }} --resource-group "${{ env.UNIQUE_PREFIX }}-${{ env.ENVIRONMENT }}-${{ env.CLUSTER_LOCATION_ACRONYM }}" --query "[?contains(name, '$SUFFIX')].properties.healthState" --output tsv)
111+
RUNNING_STATUS=$(az containerapp revision list --name ${{ inputs.image_name }} --resource-group "$CLUSTER_RESOURCE_GROUP_NAME" --query "[?contains(name, '$SUFFIX')].properties.runningState" --output tsv)
112+
HEALTH_STATUS=$(az containerapp revision list --name ${{ inputs.image_name }} --resource-group "$CLUSTER_RESOURCE_GROUP_NAME" --query "[?contains(name, '$SUFFIX')].properties.healthState" --output tsv)
112113
if [[ "$HEALTH_STATUS" == "Healthy" ]]; then
113114
echo "New revision is healthy. Running state: $RUNNING_STATUS"
114115
exit 0

.github/workflows/_deploy-infrastructure.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,33 @@ jobs:
8080
id: deploy_cluster
8181
run: bash ./cloud-infrastructure/cluster/deploy-cluster.sh ${{ inputs.unique_prefix }} ${{ inputs.azure_environment }} ${{ inputs.cluster_location }} ${{ inputs.cluster_location_acronym }} ${{ inputs.sql_admin_object_id }} ${{ inputs.domain_name }} --plan
8282

83+
- name: Show DNS Configuration
84+
if: ${{ inputs.domain_name != '' && inputs.domain_name != '-' }}
85+
run: |
86+
CLUSTER_RESOURCE_GROUP_NAME="${{ inputs.unique_prefix }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}"
87+
88+
# Try to get the Container Apps Environment details
89+
env_details=$(az containerapp env show --name $CLUSTER_RESOURCE_GROUP_NAME --resource-group $CLUSTER_RESOURCE_GROUP_NAME 2>&1 || echo "")
90+
91+
if [[ "$env_details" != "" ]] && [[ "$env_details" != *"ResourceNotFound"* ]] && [[ "$env_details" != *"ResourceGroupNotFound"* ]]; then
92+
custom_domain_verification_id=$(echo "$env_details" | jq -r '.properties.customDomainConfiguration.customDomainVerificationId')
93+
default_domain=$(echo "$env_details" | jq -r '.properties.defaultDomain')
94+
95+
# Check if app-gateway already has the custom domain configured
96+
app_gateway_details=$(az containerapp show --name app-gateway --resource-group $CLUSTER_RESOURCE_GROUP_NAME 2>&1 || echo "")
97+
custom_domains=$(echo "$app_gateway_details" | jq -r '.properties.configuration.ingress.customDomains // []')
98+
99+
if [[ "$custom_domains" != "[]" ]] && [[ "$custom_domains" != "null" ]]; then
100+
echo "$(date +"%Y-%m-%dT%H:%M:%S") Custom domain '${{ inputs.domain_name }}' is already configured correctly."
101+
else
102+
echo "$(date +"%Y-%m-%dT%H:%M:%S") Please add the following DNS entries and then retry:"
103+
echo "- A TXT record with the name 'asuid.${{ inputs.domain_name }}' and the value '$custom_domain_verification_id'."
104+
echo "- A CNAME record with the Host name '${{ inputs.domain_name }}' that points to address 'app-gateway.$default_domain'."
105+
fi
106+
else
107+
echo "$(date +"%Y-%m-%dT%H:%M:%S") DNS configuration instructions will be shown after the Container Apps Environment is created."
108+
fi
109+
83110
deploy:
84111
name: Deploy
85112
if: ${{ needs.plan.outputs.should_deploy == 'true' }}

.github/workflows/_migrate-database.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
env:
5252
UNIQUE_PREFIX: ${{ vars.UNIQUE_PREFIX }}
5353
TENANT_ID: ${{ vars.TENANT_ID }}
54-
RESOURCE_GROUP_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
54+
CLUSTER_RESOURCE_GROUP_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
5555
SQL_SERVER_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
5656
SQL_SERVER_FQDN: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}.database.windows.net
5757

@@ -82,7 +82,7 @@ jobs:
8282
- name: Open Firewall
8383
working-directory: cloud-infrastructure/cluster
8484
env:
85-
RESOURCE_GROUP_NAME: ${{ env.RESOURCE_GROUP_NAME }}
85+
CLUSTER_RESOURCE_GROUP_NAME: ${{ env.CLUSTER_RESOURCE_GROUP_NAME }}
8686
SQL_SERVER_NAME: ${{ env.SQL_SERVER_NAME }}
8787
SQL_DATABASE_NAME: ${{ inputs.database_name }}
8888
run: bash ./firewall.sh open
@@ -142,7 +142,7 @@ jobs:
142142
if: always()
143143
working-directory: cloud-infrastructure/cluster
144144
env:
145-
RESOURCE_GROUP_NAME: ${{ env.RESOURCE_GROUP_NAME }}
145+
CLUSTER_RESOURCE_GROUP_NAME: ${{ env.CLUSTER_RESOURCE_GROUP_NAME }}
146146
SQL_SERVER_NAME: ${{ env.SQL_SERVER_NAME }}
147147
SQL_DATABASE_NAME: ${{ inputs.database_name }}
148148
run: bash ./firewall.sh close
@@ -190,15 +190,15 @@ jobs:
190190
with:
191191
github-token: ${{ secrets.GITHUB_TOKEN }}
192192
script: |
193-
// Delete previous migration info comments
193+
// Delete previous migration info comments for this specific database
194194
const comments = await github.rest.issues.listComments({
195195
issue_number: context.issue.number,
196196
owner: context.repo.owner,
197197
repo: context.repo.repo,
198198
per_page: 100
199199
});
200200
201-
const MIGRATION_HEADER = '## Approve Database Migration';
201+
const MIGRATION_HEADER = '## Approve Database Migration `${{ inputs.database_name }}` database on `${{ inputs.azure_environment }}`';
202202
203203
for (const comment of comments.data) {
204204
if (comment.body && comment.body.startsWith(MIGRATION_HEADER)) {
@@ -238,7 +238,7 @@ jobs:
238238
env:
239239
UNIQUE_PREFIX: ${{ vars.UNIQUE_PREFIX }}
240240
TENANT_ID: ${{ vars.TENANT_ID }}
241-
RESOURCE_GROUP_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
241+
CLUSTER_RESOURCE_GROUP_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
242242
SQL_SERVER_NAME: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}
243243
SQL_SERVER_FQDN: ${{ vars.UNIQUE_PREFIX }}-${{ inputs.azure_environment }}-${{ inputs.cluster_location_acronym }}.database.windows.net
244244

@@ -269,7 +269,7 @@ jobs:
269269
- name: Open Firewall
270270
working-directory: cloud-infrastructure/cluster
271271
env:
272-
RESOURCE_GROUP_NAME: ${{ env.RESOURCE_GROUP_NAME }}
272+
CLUSTER_RESOURCE_GROUP_NAME: ${{ env.CLUSTER_RESOURCE_GROUP_NAME }}
273273
SQL_SERVER_NAME: ${{ env.SQL_SERVER_NAME }}
274274
SQL_DATABASE_NAME: ${{ inputs.database_name }}
275275
run: bash ./firewall.sh open
@@ -289,7 +289,7 @@ jobs:
289289
if: always()
290290
working-directory: cloud-infrastructure/cluster
291291
env:
292-
RESOURCE_GROUP_NAME: ${{ env.RESOURCE_GROUP_NAME }}
292+
CLUSTER_RESOURCE_GROUP_NAME: ${{ env.CLUSTER_RESOURCE_GROUP_NAME }}
293293
SQL_SERVER_NAME: ${{ env.SQL_SERVER_NAME }}
294294
SQL_DATABASE_NAME: ${{ inputs.database_name }}
295295
run: bash ./firewall.sh close

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
##
44
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
55

6+
# Bicep generated parameter files
7+
cloud-infrastructure/cluster/main-cluster.parameters.json
8+
69
# User-specific files
710
*.rsuser
811
*.suo

cloud-infrastructure/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Examples of cluster-specific resources:
5858
- Communication Service: `ppdemo-stage-weu`, `ppdemo-prod-eus2`
5959
- Storage Accounts: `ppdemostageweuacctmgmt`, `ppdemoprodweudiagnostic`
6060

61-
Examples of environment-specific resources:
61+
Examples of global resources (shared across all clusters in an environment):
62+
- Resource Group: `ppdemo-stage-global`, `ppdemo-prod-global`
6263
- Application Insights: `ppdemo-stage`, `ppdemo-prod`
6364
- Log Analytics workspace: `ppdemo-stage`, `ppdemo-prod`
6465
- Container Registry: `ppdemostage`, `ppdemoprod`

cloud-infrastructure/cluster/deploy-cluster.sh

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,64 @@ get_active_version()
1919
fi
2020
}
2121

22-
function is_domain_configured() {
23-
# Get details about the container apps
24-
local app_details=$(az containerapp show --name "$1" --resource-group "$2" 2>&1)
25-
if [[ "$app_details" == *"ResourceNotFound"* ]] || [[ "$app_details" == *"ResourceGroupNotFound"* ]] || [[ "$app_details" == *"ERROR"* ]] ; then
26-
echo "false"
27-
else
28-
local result=$(echo "$app_details" | jq -r '.properties.configuration.ingress.customDomains')
29-
[[ "$result" != "null" ]] && echo "true" || echo "false"
30-
fi
31-
}
3222

3323
if [[ "$DOMAIN_NAME" == "-" ]]; then
3424
# "-" is used to indicate that the domain is not configured
3525
DOMAIN_NAME=""
3626
fi
3727

38-
CONTAINER_REGISTRY_NAME=$UNIQUE_PREFIX$ENVIRONMENT
39-
ENVIRONMENT_RESOURCE_GROUP_NAME="$UNIQUE_PREFIX-$ENVIRONMENT"
40-
RESOURCE_GROUP_NAME="$ENVIRONMENT_RESOURCE_GROUP_NAME-$CLUSTER_LOCATION_ACRONYM"
41-
IS_DOMAIN_CONFIGURED=$(is_domain_configured "app-gateway" "$RESOURCE_GROUP_NAME")
28+
export UNIQUE_PREFIX
29+
export ENVIRONMENT
30+
export LOCATION=$CLUSTER_LOCATION
31+
export DOMAIN_NAME
32+
export SQL_ADMIN_OBJECT_ID
33+
34+
export CONTAINER_REGISTRY_NAME=$UNIQUE_PREFIX$ENVIRONMENT
35+
export GLOBAL_RESOURCE_GROUP_NAME="$UNIQUE_PREFIX-$ENVIRONMENT-global"
36+
export CLUSTER_RESOURCE_GROUP_NAME="$UNIQUE_PREFIX-$ENVIRONMENT-$CLUSTER_LOCATION_ACRONYM"
4237

43-
APP_GATEWAY_VERSION=$(get_active_version "app-gateway" $RESOURCE_GROUP_NAME)
44-
ACTIVE_ACCOUNT_MANAGEMENT_VERSION=$(get_active_version "account-management-api" $RESOURCE_GROUP_NAME) # The version from the API is use for both API and Workers
45-
ACTIVE_BACK_OFFICE_VERSION=$(get_active_version "back-office-api" $RESOURCE_GROUP_NAME) # The version from the API is use for both API and Workers
38+
export APP_GATEWAY_VERSION=$(get_active_version "app-gateway" $CLUSTER_RESOURCE_GROUP_NAME)
39+
export ACCOUNT_MANAGEMENT_VERSION=$(get_active_version "account-management-api" $CLUSTER_RESOURCE_GROUP_NAME) # The version from the API is use for both API and Workers
40+
export BACK_OFFICE_VERSION=$(get_active_version "back-office-api" $CLUSTER_RESOURCE_GROUP_NAME) # The version from the API is use for both API and Workers
4641

47-
az extension add --name application-insights --allow-preview true
48-
APPLICATIONINSIGHTS_CONNECTION_STRING=$(az monitor app-insights component show --app $UNIQUE_PREFIX-$ENVIRONMENT --resource-group $UNIQUE_PREFIX-$ENVIRONMENT --query connectionString --output tsv)
42+
az extension add --name application-insights --allow-preview true --only-show-errors
43+
44+
# Check if Application Insights exists before trying to get connection string
45+
if az group exists --name $GLOBAL_RESOURCE_GROUP_NAME 2>/dev/null | grep -q "true"; then
46+
export APPLICATIONINSIGHTS_CONNECTION_STRING=$(az monitor app-insights component show --app $UNIQUE_PREFIX-$ENVIRONMENT --resource-group $GLOBAL_RESOURCE_GROUP_NAME --query connectionString --output tsv)
47+
else
48+
export APPLICATIONINSIGHTS_CONNECTION_STRING=""
49+
fi
4950

5051
CURRENT_DATE=$(date +'%Y-%m-%dT%H-%M')
51-
DEPLOYMENT_COMMAND="az deployment sub create"
52-
DEPLOYMENT_PARAMETERS="-l $CLUSTER_LOCATION -n $CURRENT_DATE-$RESOURCE_GROUP_NAME --output json -f ./main-cluster.bicep -p resourceGroupName=$RESOURCE_GROUP_NAME environmentResourceGroupName=$ENVIRONMENT_RESOURCE_GROUP_NAME environment=$ENVIRONMENT containerRegistryName=$CONTAINER_REGISTRY_NAME domainName=$DOMAIN_NAME isDomainConfigured=$IS_DOMAIN_CONFIGURED sqlAdminObjectId=$SQL_ADMIN_OBJECT_ID appGatewayVersion=$APP_GATEWAY_VERSION accountManagementVersion=$ACTIVE_ACCOUNT_MANAGEMENT_VERSION backOfficeVersion=$ACTIVE_BACK_OFFICE_VERSION applicationInsightsConnectionString=$APPLICATIONINSIGHTS_CONNECTION_STRING"
52+
export REVISION_SUFFIX=$(printf "%04x" $RANDOM | head -c 4)
5353

5454
cd "$(dirname "${BASH_SOURCE[0]}")"
55+
56+
# Build the .bicepparam file to generate parameters.json
57+
bicep build-params ./main-cluster.bicepparam --outfile ./main-cluster.parameters.json
58+
59+
DEPLOYMENT_COMMAND="az deployment sub create"
60+
DEPLOYMENT_PARAMETERS="-l $CLUSTER_LOCATION -n $CURRENT_DATE-$CLUSTER_RESOURCE_GROUP_NAME --output json -f ./main-cluster.bicep -p ./main-cluster.parameters.json"
61+
5562
. ../deploy.sh
5663

57-
# When initially creating the Azure Container App with SSL and a custom domain, we need to run the deployment three times (see https://github.com/microsoft/azure-container-apps/tree/main/docs/templates/bicep/managedCertificates):
58-
# 1. On the initial run, the deployment will fail, providing instructions on how to manually create DNS TXT and CNAME records. After doing so, the workflow must be run again.
59-
# 2. The second time, the DNS will be configured, and a certificate will be created. However, they will not be bound together, as this is a two-step process and they cannot be created in a single deployment.
60-
# 3. The third deployment will bind the SSL Certificate to the Domain. This step will be triggered automatically.
64+
# When initially creating the Azure Container App with SSL and a custom domain, the deployment may fail if DNS records are not configured.
65+
# With bindingType: 'Auto' (API version 2025-07-01), certificates are created and bound in a single deployment.
66+
# If the deployment fails, ensure DNS records are properly configured:
67+
# - A TXT record: asuid.<domain> with the customDomainVerificationId value
68+
# - A CNAME record: <domain> pointing to the container app's default domain
6169
if [[ "$*" == *"--apply"* ]]
6270
then
6371
RED='\033[0;31m'
6472
RESET='\033[0m' # Reset formatting
6573

6674
cleaned_output=$(echo "$output" | sed '/^WARNING/d' | sed '/^\/home\/runner\/work\//d')
6775
# Check for the specific error message indicating that DNS Records are missing
68-
if [[ $cleaned_output == *"InvalidCustomHostNameValidation"* ]] || [[ $cleaned_output == *"FailedCnameValidation"* ]] || [[ $cleaned_output == *"-certificate' under resource group '$RESOURCE_GROUP_NAME' was not found"* ]]; then
69-
# Get details about the container apps environment. Although the creation of the container app fails, the verification ID on the container apps environment is consistent across all container apps.
70-
env_details=$(az containerapp env show --name $RESOURCE_GROUP_NAME --resource-group $RESOURCE_GROUP_NAME)
71-
76+
if [[ $cleaned_output == *"InvalidCustomHostNameValidation"* ]] || [[ $cleaned_output == *"FailedCnameValidation"* ]]; then
77+
# Get details about the container apps environment to provide DNS configuration instructions
78+
env_details=$(az containerapp env show --name $CLUSTER_RESOURCE_GROUP_NAME --resource-group $CLUSTER_RESOURCE_GROUP_NAME)
79+
7280
# Extract the customDomainVerificationId and defaultDomain from the container apps environment
7381
custom_domain_verification_id=$(echo "$env_details" | jq -r '.properties.customDomainConfiguration.customDomainVerificationId')
7482
default_domain=$(echo "$env_details" | jq -r '.properties.defaultDomain')
@@ -83,20 +91,6 @@ then
8391
exit 1
8492
fi
8593

86-
# If the domain was not configured during the first run and we didn't receive any warnings about missing DNS entries, we trigger the deployment again to complete the binding of the SSL Certificate to the domain.
87-
if [[ "$IS_DOMAIN_CONFIGURED" == "false" ]] && [[ "$DOMAIN_NAME" != "" ]]; then
88-
echo "Running deployment again to finalize setting up SSL certificate for $DOMAIN_NAME"
89-
IS_DOMAIN_CONFIGURED=$(is_domain_configured "app-gateway" $RESOURCE_GROUP_NAME)
90-
DEPLOYMENT_PARAMETERS="-l $CLUSTER_LOCATION -n $CURRENT_DATE-$RESOURCE_GROUP_NAME --output json -f ./main-cluster.bicep -p resourceGroupName=$RESOURCE_GROUP_NAME environmentResourceGroupName=$ENVIRONMENT_RESOURCE_GROUP_NAME environment=$ENVIRONMENT containerRegistryName=$CONTAINER_REGISTRY_NAME domainName=$DOMAIN_NAME isDomainConfigured=$IS_DOMAIN_CONFIGURED sqlAdminObjectId=$SQL_ADMIN_OBJECT_ID appGatewayVersion=$APP_GATEWAY_VERSION accountManagementVersion=$ACTIVE_ACCOUNT_MANAGEMENT_VERSION backOfficeVersion=$ACTIVE_BACK_OFFICE_VERSION applicationInsightsConnectionString=$APPLICATIONINSIGHTS_CONNECTION_STRING"
91-
. ../deploy.sh
92-
93-
cleaned_output=$(echo "$output" | sed '/^WARNING/d' | sed '/^\/home\/runner\/work\//d')
94-
if [[ $cleaned_output == "ERROR:"* ]]; then
95-
echo -e "${RED}$output"
96-
exit 1
97-
fi
98-
fi
99-
10094
# Extract the ID of the Managed Identities, which can be used to grant access to SQL Database
10195
ACCOUNT_MANAGEMENT_IDENTITY_CLIENT_ID=$(echo "$cleaned_output" | jq -r '.properties.outputs.accountManagementIdentityClientId.value')
10296
BACK_OFFICE_IDENTITY_CLIENT_ID=$(echo "$cleaned_output" | jq -r '.properties.outputs.backOfficeIdentityClientId.value')

cloud-infrastructure/cluster/firewall.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ FIREWALL_RULE_NAME="GitHub Action Workflows - ${SQL_DATABASE_NAME} - Only active
44
if [[ "$1" == "open" ]]
55
then
66
echo "$(date +"%Y-%m-%dT%H:%M:%S") Add the IP $IP_ADDRESS to the SQL Server firewall on server $SQL_SERVER_NAME for database $SQL_DATABASE_NAME"
7-
az sql server firewall-rule create --resource-group $RESOURCE_GROUP_NAME --server $SQL_SERVER_NAME --name "$FIREWALL_RULE_NAME" --start-ip-address $IP_ADDRESS --end-ip-address $IP_ADDRESS
7+
az sql server firewall-rule create --resource-group $CLUSTER_RESOURCE_GROUP_NAME --server $SQL_SERVER_NAME --name "$FIREWALL_RULE_NAME" --start-ip-address $IP_ADDRESS --end-ip-address $IP_ADDRESS
88
else
99
echo "$(date +"%Y-%m-%dT%H:%M:%S") Delete the IP $IP_ADDRESS from the SQL Server firewall on server $SQL_SERVER_NAME for database $SQL_DATABASE_NAME"
10-
az sql server firewall-rule delete --resource-group $RESOURCE_GROUP_NAME --server $SQL_SERVER_NAME --name "$FIREWALL_RULE_NAME"
10+
az sql server firewall-rule delete --resource-group $CLUSTER_RESOURCE_GROUP_NAME --server $SQL_SERVER_NAME --name "$FIREWALL_RULE_NAME"
1111
fi

0 commit comments

Comments
 (0)