Backfilling Azure Owner Tags on Legacy Resource Groups

Tagging often begins as a governance requirement and quickly becomes an operational necessity. In Azure, one of the most important tags is often Owner, because it answers a basic but critical question: who is responsible for this resource?

In a mature environment, that answer should be easy to find. In reality, many Azure estates contain a mix of old and new deployments. Newer resources may follow a tagging standard enforced by policy, while older resource groups and resources were created before that standard existed. The result is a common governance gap: the standard exists today, but parts of the existing estate still have missing tags.

A practical way to solve this is to start at the resource group level.

The legacy tagging problem

Imagine an enterprise with several domains, such as integration, analytics, ERP, customer platforms, and internal tooling. Over time, each domain has built up its own Azure resource groups and resources. Later, the organization introduces a governance standard requiring every resource to have an Owner tag.

Azure Policy is well suited to enforce that standard going forward. But older resource groups may never have received an Owner tag in the first place. If the parent resource group has no Owner tag, there is nothing for child resources to inherit.

That creates a gap:

This is where a small PowerShell script becomes useful.

Why a script still makes sense when Azure Policy exists

Azure Policy is the right long-term control. It gives you centralized enforcement, compliance visibility, and remediation support across subscriptions and management groups.

But a script can still be the right short-term tool.

A manual script is useful when you need to backfill a missing tag on a known set of legacy resource groups, especially when those groups belong to a specific domain and can be identified by a naming convention. In that case, the script is not replacing policy. It is preparing the environment so policy can work as intended.

That is the key distinction:

The recommended pattern

A practical governance pattern for this scenario looks like this:

  1. Identify the legacy resource groups that belong to a domain and should share the same ownership value
  2. Stamp the Owner tag onto those resource groups
  3. Assign an Azure Policy that makes child resources inherit the Owner tag from the resource group when it is missing

This approach works especially well when the resource group represents a clear ownership boundary inside the enterprise. That could be a business domain, an application domain, a platform team, or a product area.

Example scenario

Suppose an enterprise has multiple domains, and one of them is the finance domain. That domain contains resource groups such as:

These resource groups were created before the Owner tag standard was introduced. The enterprise now wants all resources in that domain to be associated with the same owner, such as finance-platform@contoso.com.

Instead of opening each resource group manually in the Azure portal, a script can add the Owner tag to all matching resource groups in that domain. After that, Azure Policy can propagate the same ownership value to child resources that are missing it.

The important point is that the logic is based on domain ownership, not on one specific workload like a data lake.

The script

The following PowerShell function finds resource groups by name prefix and stamps the Owner tag. It supports -WhatIf for safe preview before making changes, and preserves any existing tags on the resource groups.

Key design decisions

Prefix-based matching allows grouping by domain convention rather than listing individual resource groups. This scales well when a domain has many resource groups across environments.

WhatIf support through SupportsShouldProcess lets you preview exactly which resource groups will be changed before committing. Always run with -WhatIf first.

Preserving existing tags is critical. The function copies all existing tags and only adds or updates the Owner tag. It never removes tags that are already present.

Optional overwrite via the -OverwriteExisting switch lets you correct an incorrect owner value without affecting resource groups that already have the correct one.

What comes after the script

Once the resource groups have the Owner tag, the next step is to assign an Azure Policy with the Inherit a tag from the resource group if missing effect. This policy will automatically propagate the Owner tag to new and existing child resources that are missing it.

The combination of a one-time script for backfill and an ongoing policy for enforcement gives you a clean, maintainable governance model.

Daniel Moquist

Author

January 17, 2024

Daniel Moquist

Cloud Architect & DevOps Expert