[FEATURE REQUEST] Ability to inject custom tags
Ask
It would be amazing to have a way to set an environment variable in your dev environment with a list of custom tags that you want applied to any AZD deployment. It would be even better if there's a way to do this without modifying existing templates.
Context
It's not uncommon to have requirements on your Azure subscription to tag your deployments with metadata like:
created-by:<your-principal>
deployment-type:<automated>
<something-else>:<some-value>
Today, I need to modify any AZD template I pull down to add this functionality.
In a perfect world, I could have either an environment variable or some special *.env file (bonus points for recursive lookup) where I can define custom tags that should be applied to any AZD deployment I create.
Research
I searched the documentation and this repository to see if someone has brought this up before. If I missed another issue, I apologize.
Do you need those tags apply to each individual resource within that deployment? You'd be great if you could show (in detail) what you do today, just to make sure that whatever we implement addresses that scenario.
I've been asked to do both before by different people as a way to track costs in Azure subscriptions.
- Apply a tag like
created-by: <alias>to all resources within a resource group to help a manager visualize costs in a shared subscription by team member - Apply a tag like
automation: trueto resource groups so it's known it was created by automation and not by person.
In reality, I'm asked to create tags for a myriad of reasons. In my own AZD templates, I can accomplish it today by manually editing the template and adding more content to the var tags. Unfortunately, this is a var in most templates so there's really no way to say, for example "anytime I deploy an AZD template, apply the created-by: seesharprun to all resources/or and the resource group."
Today, I accomplish this by running this type of command in PowerShell using Azure CLI:
az group update --resource-group "<resource-group-name>" --tags "key=value"
foreach ($resource in (az resource list --resource-group "<resource-group-name>" | ConvertFrom-Json)) {
az resource tag --is-incremental --resource-group "<resource-group-name>" --name $resource.name --resource-type $resource.type --tags "key=value"
}
In a perfect world, I could have some type of environment file either in the template directory or a parent directory (think like .vscode settings) where I can configure some resource-group, subscription, or resource level auto-tags to apply.
This is SUPER low priority, but I just thought I would put it on your radar since today I'm tagging things manually after running the AZD deployment. Please feel free to push this to the back of your backlog :smile:
Could this be a potential candidate for an extension @wbreza ?
I think something like azd tag-resources .... where folks can:
- define their own ENV VARS or input files for adding tags to the resources created by azd.
azd would provide the library to get the list of resources and apply tags.
The only downside would be that calling provision would re-set all tags to what is defined in bicep, so the extension would need to become a postprovision hook to keep the state.
Extensions/plugins would solve this for me. I know that work is planned in https://github.com/Azure/azure-dev/issues/3565