Add tags parameter to main.bicep with enhanced example values and deployment-time CreatedOn - #41
Add tags parameter to main.bicep with enhanced example values and deployment-time CreatedOn#41wesmacdonald with Copilot wants to merge 3 commits into
Conversation
…in.bicepparam Agent-Logs-Url: https://github.com/LIKE10/ContainerJobExample/sessions/4d113d98-7eb5-4cef-aabb-658d3a98bb7e Co-authored-by: wesmacdonald <1325956+wesmacdonald@users.noreply.github.com>
wesmacdonald
left a comment
There was a problem hiding this comment.
Created on should be calculated at deployment time
// Define tags as a parameter with default values
@description('Resource tags for all resources')
param tags object = {
Environment: 'Development'
Owner: 'team@company.com'
CostCenter: 'CC1234'
Project: 'MyApplication'
Department: 'Engineering'
CreatedOn: utcNow('yyyy-MM-dd')
Confidentiality: 'Internal'
}
// Example: Apply tags to a storage account
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'mystorageaccount'
location: resourceGroup().location
tags: tags
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
Agent-Logs-Url: https://github.com/LIKE10/ContainerJobExample/sessions/57ea6064-d558-42b3-b1b1-ff474faf6f1e Co-authored-by: wesmacdonald <1325956+wesmacdonald@users.noreply.github.com>
Done in a597349. Since Bicep restricts |
infra/main.bicephad no tagging support, leaving all provisioned resources untagged. This adds atagsparameter and propagates it to every resource in the template. TheCreatedOntag is automatically computed at deployment time usingutcNow('yyyy-MM-dd')rather than being hardcoded.Changes
infra/main.bicep— newtagsparameter with sensible defaults applied to all five resources (Log Analytics Workspace, Application Insights, Container Apps Environment, Manual Job, Scheduled Job); a dedicatedparam createdOn string = utcNow('yyyy-MM-dd')parameter computes the creation date at deployment time; aresourceTagsvariable merges the two viaunion(tags, { CreatedOn: createdOn })infra/main.bicepparam— populatedtagswith the full recommended tag set (no hardcodedCreatedOndate — it is now always the actual deployment timestamp)