From d940bb1d3a87dae9969e48abca2fe79709669a55 Mon Sep 17 00:00:00 2001 From: Harmanpreet-Microsoft Date: Fri, 12 Sep 2025 11:39:20 +0530 Subject: [PATCH 1/5] Add createdDate parameter for deployment timestamp --- infra/main.bicep | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infra/main.bicep b/infra/main.bicep index f3c9f956..23621798 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -136,7 +136,8 @@ var abbrs = loadJsonContent('./abbreviations.json') @description('Optional created by user name') param createdBy string = empty(deployer().userPrincipalName) ? '' : split(deployer().userPrincipalName, '@')[0] - +@description('Deployment UTC timestamp') +param createdDate string ='yyyy-MM-ddTHH:mm:ssZ' // ========== Resource Group Tag ========== // resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { name: 'default' @@ -145,6 +146,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { ...allTags TemplateName: 'Code Modernization' CreatedBy: createdBy + CreatedDate:createdDate } } } From d4595bc9f271b1080ac58a68df5d31d6782d416a Mon Sep 17 00:00:00 2001 From: Harmanpreet-Microsoft Date: Fri, 12 Sep 2025 11:43:38 +0530 Subject: [PATCH 2/5] Change createdDate to use utcNow function Updated createdDate parameter to use utcNow function. --- infra/main.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/main.bicep b/infra/main.bicep index 23621798..2125d9ed 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -137,7 +137,7 @@ var abbrs = loadJsonContent('./abbreviations.json') @description('Optional created by user name') param createdBy string = empty(deployer().userPrincipalName) ? '' : split(deployer().userPrincipalName, '@')[0] @description('Deployment UTC timestamp') -param createdDate string ='yyyy-MM-ddTHH:mm:ssZ' +param createdDate string = any('utcNow(''yyyy-MM-ddTHH:mm:ssZ'')') // ========== Resource Group Tag ========== // resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { name: 'default' From 3eb926872837d368b982c632ff1a225638eef35b Mon Sep 17 00:00:00 2001 From: Harmanpreet-Microsoft Date: Tue, 16 Sep 2025 11:51:57 +0530 Subject: [PATCH 3/5] Assign Contributor role to Service Principal Add role assignment step for Service Principal in deployment workflow. --- .github/workflows/deploy.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c2158ad5..be98168f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -137,6 +137,15 @@ jobs: capacity=${{ env.GPT_MIN_CAPACITY }} \ imageVersion="${IMAGE_TAG}" \ createdBy="Pipeline" + - name: Assign Contributor role to Service Principal + if: always() + run: | + echo "Assigning Contributor role to SPN for RG: ${{ env.RESOURCE_GROUP_NAME }}" + az role assignment create \ + --assignee ${{ secrets.AZURE_CLIENT_ID }} \ + --role "Contributor" \ + --scope /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ env.RESOURCE_GROUP_NAME }} + - name: Get Deployment Output and extract Values id: get_output From 90bfbaa4c4cb3f198c5358f2003fd14a05d267a7 Mon Sep 17 00:00:00 2001 From: Harmanpreet-Microsoft Date: Tue, 16 Sep 2025 11:55:47 +0530 Subject: [PATCH 4/5] Remove createdDate parameter from main.bicep Removed createdDate parameter from deployment. --- infra/main.bicep | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 2125d9ed..efc9c034 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -136,8 +136,7 @@ var abbrs = loadJsonContent('./abbreviations.json') @description('Optional created by user name') param createdBy string = empty(deployer().userPrincipalName) ? '' : split(deployer().userPrincipalName, '@')[0] -@description('Deployment UTC timestamp') -param createdDate string = any('utcNow(''yyyy-MM-ddTHH:mm:ssZ'')') + // ========== Resource Group Tag ========== // resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { name: 'default' @@ -146,7 +145,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { ...allTags TemplateName: 'Code Modernization' CreatedBy: createdBy - CreatedDate:createdDate + } } } From 8420eae443ad0808c4ba019ce8cbd2ef6fa67585 Mon Sep 17 00:00:00 2001 From: Harmanpreet-Microsoft Date: Tue, 16 Sep 2025 14:10:07 +0530 Subject: [PATCH 5/5] Remove trailing newline in Bicep file --- infra/main.bicep | 1 - 1 file changed, 1 deletion(-) diff --git a/infra/main.bicep b/infra/main.bicep index efc9c034..f3c9f956 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -145,7 +145,6 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = { ...allTags TemplateName: 'Code Modernization' CreatedBy: createdBy - } } }