chore: Add tags in resource group when deployment is in pre-provision state#156
Open
NirajC-Microsoft wants to merge 2 commits into
Open
chore: Add tags in resource group when deployment is in pre-provision state#156NirajC-Microsoft wants to merge 2 commits into
NirajC-Microsoft wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds resource-group tagging during preprovision and expands the Bicep resource-group tag set to include environment and location metadata.
Changes:
- Adds resource group tag update logic to Bash and PowerShell preprovision scripts.
- Adds
azd-env-nameandLocationtags to the Bicep resource group tags resource. - Attempts to align tag values such as
TemplateName,Type, andCreatedByacross scripts and infrastructure.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
scripts/preprovision-integrated.sh |
Adds resource group tag handling before AI Landing Zone preprovision. |
scripts/preprovision-integrated.ps1 |
Adds equivalent PowerShell resource group tag handling before deployment. |
infra/main.bicep |
Extends resource group tags with environment name and location. |
Comments suppressed due to low confidence (4)
scripts/preprovision-integrated.sh:108
- This block never creates the resource group when
az group existsreturnsfalse; it skips the update and still prints that the group is ready. Because this preprovision script later deploys to$AZURE_RESOURCE_GROUP, first-time local runs where the group does not already exist will fail despite the PR goal of pre-creating the tagged resource group.
RG_EXISTS="$(az group exists --name "$AZURE_RESOURCE_GROUP" --subscription "$AZURE_SUBSCRIPTION_ID" 2>/dev/null || echo 'false')"
if [ "$RG_EXISTS" = "true" ]; then
# RG exists — merge tags without removing existing ones
az tag update \
--resource-id "/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$AZURE_RESOURCE_GROUP" \
--operation Merge \
--tags \
"TemplateName=Deploy Your AI Application in Prod" \
"Type=$TYPE_TAG" \
"CreatedBy=$CREATED_BY" \
"Location=$AZURE_LOCATION" \
--only-show-errors > /dev/null
fi
scripts/preprovision-integrated.sh:94
- The Type tag defaults to
Non-WAFwheneverNETWORK_ISOLATIONis not explicitly set, butinfra/main.bicepparamsetsnetworkIsolation = trueby default. In the normal azd path without a NETWORK_ISOLATION env value, the preprovision tag will sayNon-WAFwhile the Bicep deployment tags the same group asWAF.
# Type tag based on networkIsolation setting
NETWORK_ISOLATION_VALUE="${NETWORK_ISOLATION:-false}"
if [ "$NETWORK_ISOLATION_VALUE" = "true" ]; then
TYPE_TAG="WAF"
else
TYPE_TAG="Non-WAF"
fi
scripts/preprovision-integrated.sh:107
- The preprovision tag set omits the
azd-env-nametag that this PR adds toinfra/main.bicep, so the script and Bicep tag logic are still not aligned. A resource group created/updated in preprovision will be missing the environment-name metadata until the later Bicep deployment succeeds.
--tags \
"TemplateName=Deploy Your AI Application in Prod" \
"Type=$TYPE_TAG" \
"CreatedBy=$CREATED_BY" \
"Location=$AZURE_LOCATION" \
--only-show-errors > /dev/null
scripts/preprovision-integrated.ps1:228
- The preprovision tag set omits the
azd-env-nametag that this PR adds toinfra/main.bicep, so the provisioning script and Bicep tag logic are not actually aligned. If preprovision creates or updates the group before the main deployment, the environment-name metadata is absent until the Bicep deployment completes.
$rgTags = @(
"TemplateName=Deploy Your AI Application in Prod"
"Type=$typeTag"
"CreatedBy=$createdBy"
"Location=$($env:AZURE_LOCATION)"
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request improves the way resource group tags are handled during deployment, ensuring consistency and completeness of metadata across both infrastructure code and provisioning scripts. The main enhancements include pre-creating or updating the resource group with a standardized set of tags and aligning tag logic between Bicep templates and provisioning scripts.
Resource Group Tagging Improvements:
Both
preprovision-integrated.ps1andpreprovision-integrated.shscripts now ensure the resource group exists and is updated with standardized tags before proceeding. These tags includeTemplateName,Type(based on network isolation),CreatedBy(derived from user context), andLocation. This logic matches the Bicep template to maintain consistency. [1] [2]The Bicep template for resource group tags (
resourceGroupTagsinmain.bicep) is updated to add theazd-env-nameandLocationtags, ensuring these values are always present in the deployment metadata.Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information