Skip to main content

CSV-Powered Tagging Recipes for Azure & OCI

No-fuss CSV tagging scripts for Azure RGs & OCI compartments—serve up tags with a single file.

BeginnerAutomation15 minutes setup + 5 minutes per runAzureOCI

Standardized doc shell (hero + metadata + quick path). Custom content below remains page-specific.

Download Tool Files
Blaze
Blaze says:Pro move: keep your tag CSV in version control. When finance asks 'who changed the cost center on that RG last Tuesday?' you'll have the commit history to prove it. These scripts merge tags by default, so existing tags won't get nuked.

Standard run path

Structured quick-reference sections for prerequisites, installation, usage, and troubleshooting.

Prerequisites

  • Python 3.6+ available on the machine running the scripts
  • Cloud credentials configured for the target Azure subscription / OCI tenancy
  • A validated CSV file with required columns (Environment, Owner, CostCenter, Project, Application)
  • Tagging permissions on the target resource groups or compartments

Installation

  1. 1Download the combined tagging tools package and verify checksum before use.
  2. 2Extract the archive and review both scripts plus the sample CSV format.
  3. 3Create a small test CSV covering 1–2 target scopes before bulk execution.
  4. 4Back up current tags (or export inventory) if you need rollback visibility.

Bulk writes require discipline

Run against a small sample first. CSV-driven tools can update many targets quickly, which is exactly why they need a controlled rollout.

Usage

Use the detailed tabbed examples below for exact command syntax and provider-specific behavior.

  1. 1Pick the Azure or OCI workflow tab below and confirm the required CSV columns.
  2. 2Run the script on a small sample set and inspect logs/output.
  3. 3Validate resulting tags in the portal/console before expanding scope.
  4. 4Commit the CSV to version control to keep an audit trail of tag changes.

Troubleshooting

  • CSV parse issues are usually column names, delimiters, or hidden characters.
  • Permission errors usually indicate missing tag write access on the target scope.
  • Unexpected tag values usually come from whitespace/formatting in the CSV source.
  • Review script logs after each run and re-test with a reduced CSV sample.

Overview

Think of these CSV-powered tagging tools as your FinOps sous-chefs—just feed them a simple CSV and they’ll sprinkle the five essential tags (Environment, Owner, CostCenter, Project, Application) onto your Azure RGs and OCI compartments, keeping your cloud kitchen organized and cost-savvy.

CloudCostChefs Azure RG Tag Chef

Whip up consistent tags across all your Azure Resource Groups in a snap—just feed it a CSV and watch the magic happen.

CloudCostChefs OCI Compartment Tag Chef

Serve up standardized tags across all your OCI compartments—just feed it a CSV and watch it cook up consistency and cost clarity.

Why Use These Tools?

Sure, the portals have tagging buttons—but these scripts let you:

  • Tag dozens of resources in one swoop
  • Keep tags uniform across your entire organization
  • Bake tagging into your automation pipelines
  • Capture every tag change in detailed logs

Key Features

CSV-Driven

A plain CSV means even non-techy teammates can update tags—no code wizardry needed.

Core Tag Ingredients

We zero in on the five must-have tags—Environment, Owner, CostCenter, Project, and Application—to keep your cloud costs in check and your resources well-seasoned.

Minimal Dependencies

All you need is pandas and the Azure or OCI SDK—no extra garnish, quick to install, and ready to run.

Detailed Logging

Every tagging action is logged to both console and file—so you’ll have a clear audit trail and troubleshooting breadcrumbs whenever you need them.

Tag Merger Magic

Keeps your old tags intact and blends in new ones—no empty-handed tag overwrites here.

Error Resilience

If one resource throws a tantrum, the script keeps cooking—no full-stop failures here.

Prerequisites

Azure Prerequisites

  1. Python 3.6+ installed on your system
  2. Required Python packages:
    bash
    pip install pandas azure-identity azure-mgmt-resource
  3. Azure CLI installed and configured with appropriate permissions:
    bash
    # Login to Azure az login  # Verify you have the correct permissions az account show
  4. Permissions: You need at least Reader and Tag Contributor role on the resource groups you want to tag

CSV Format

Azure CSV Format

Create a CSV file named ResourceGroup_Tags.csv with the following columns:

csv
ResourceGroupName,SubscriptionId,Environment,Owner,CostCenter,Project,Application

Example entries:

csv
rg-finance-prod,12345678-1234-1234-1234-123456789012,Production,jane.doe@example.com,FIN1234,ERP-Migration,ERP-App rg-devops-dev,87654321-4321-4321-4321-987654321098,Development,john.smith@example.com,ENG5678,CI-CD,Build-Pipeline
Required Columns

Only ResourceGroupName and SubscriptionId are required. The tag columns (Environment, Owner, CostCenter, Project, Application) are optional, but you should include at least one tag column for the script to be useful.

Installation & Setup

Azure Setup

  1. Download the Azure Resource Group Tagger script:
  2. Create a directory for your tagging operations:
    bash
    mkdir -p azure-tagging/logs
  3. Place the script in the directory:
    bash
    mv azure_rg_tagger.py azure-tagging/
  4. Create your CSV file (see CSV Format section) and place it in the same directory:
    bash
    # Example: Create a simple CSV echo 'ResourceGroupName,SubscriptionId,Environment,Owner,CostCenter,Project,Application' > azure-tagging/ResourceGroup_Tags.csv echo 'rg-example,12345678-1234-1234-1234-123456789012,Production,admin@example.com,IT001,Core-Infra,Monitoring' >> azure-tagging/ResourceGroup_Tags.csv
  5. Make the script executable:
    bash
    chmod +x azure-tagging/azure_rg_tagger.py

Usage

Running the Azure Tagger

  1. Navigate to your script directory:
    bash
    cd azure-tagging
  2. Run the script:
    bash
    ./azure_rg_tagger.py
  3. Check the output in the console and the log file:
    bash
    cat logs/azure_rg_tagger.log

Environment Variables

You can customize the script behavior with these environment variables:

  • RESOURCE_GROUP_CSV_PATH - Path to your CSV file (default: ./ResourceGroup_Tags.csv)
  • LOG_DIR - Directory for log files (default: ./logs)

Example with Custom CSV Path

bash
RESOURCE_GROUP_CSV_PATH=/path/to/my/custom_tags.csv ./azure_rg_tagger.py

Customization

Customizing the Azure Tagger

Adding Custom Tags

To add custom tags beyond the default five, modify the prepare_tags function in the script:

python
def prepare_tags(row): # Original tags tags = {} if pd.notnull(row.get('Environment')): tags['Environment'] = str(row['Environment']).strip() if pd.notnull(row.get('Owner')): tags['Owner'] = str(row['Owner']).strip() if pd.notnull(row.get('CostCenter')): tags['CostCenter'] = str(row['CostCenter']).strip() if pd.notnull(row.get('Project')): tags['Project'] = str(row['Project']).strip() if 'Application' in row and pd.notnull(row.get('Application')): tags['Application'] = str(row['Application']).strip()  # Add your custom tag if 'Department' in row and pd.notnull(row.get('Department')): tags['Department'] = str(row['Department']).strip()  return tags

Changing Log Format

To modify the logging format, update the logging.basicConfig call:

python
logging.basicConfig( filename=LOG_FILENAME, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s' # Custom format )

Adding Email Notifications

To add email notifications when tagging is complete, add this function and call it at the end of main():

python
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart  def send_notification_email(log_file, recipients): # Read the log file with open(log_file, 'r') as f: log_content = f.read()  # Create email msg = MIMEMultipart() msg['Subject'] = 'Azure Resource Group Tagging Complete' msg['From'] = 'your-email@example.com' msg['To'] = ', '.join(recipients)  body = f''' Azure Resource Group tagging process has completed.  Summary: {log_content[-500:]} # Last 500 characters of log  Full log attached. ''' msg.attach(MIMEText(body, 'plain'))  # Add log as attachment attachment = MIMEText(log_content) attachment.add_header('Content-Disposition', 'attachment', filename='tagging_log.txt') msg.attach(attachment)  # Send email try: server = smtplib.SMTP('smtp.example.com', 587) server.starttls() server.login('your-email@example.com', 'your-password') server.send_message(msg) server.quit() logging.info(f'Notification email sent to {recipients}') except Exception as e: logging.error(f'Failed to send notification email: {e}')

Troubleshooting

Azure Troubleshooting

Authentication Errors

If you see authentication errors:

  1. Ensure you're logged in with Azure CLI: az login
  2. Check if your credentials have expired and re-login if necessary
  3. Verify you have the correct permissions on the target subscriptions

Resource Group Not Found

If you see"Resource Group not found" errors:

  1. Verify the resource group name is spelled correctly in your CSV
  2. Check that the subscription ID is correct
  3. Confirm the resource group exists in the specified subscription

CSV Format Issues

If you see CSV parsing errors:

  1. Ensure your CSV has the correct headers
  2. Check for special characters or encoding issues in your CSV
  3. Try opening and resaving the CSV in a text editor with UTF-8 encoding

Best Practices

Consistent Naming

Use consistent tag values across your organization:

  • Standardize environment names (e.g.,"Production","Development","Testing")
  • Use email addresses for Owner tags
  • Use established cost center codes

Automation Integration

Integrate tagging into your workflows:

  • Run the script as part of your CI/CD pipeline
  • Schedule regular tagging updates
  • Combine with tag enforcement policies

CSV Management

Maintain your CSV files effectively:

  • Store CSV files in version control
  • Document the purpose and owner of each CSV
  • Consider using a central database or spreadsheet as the source of truth

Validation & Testing

Ensure your tagging operations are reliable:

  • Test on non-production resources first
  • Validate CSV data before running the script
  • Review logs after each run to catch any issues
Tag Inheritance

Remember that in both Azure and OCI, tags are not automatically inherited by child resources. Consider implementing additional tagging strategies for individual resources if needed.

Next Steps

After implementing these tagging tools, consider these next steps to enhance your cloud cost management:

Tag-Based Reporting

Leverage your tags for cost analysis:

  • Create cost reports grouped by Environment, CostCenter, or Project
  • Set up dashboards to visualize spending by tag
  • Share reports with stakeholders based on their tags

Tag Enforcement

Ensure consistent tagging across your organization:

  • Implement Azure Policy or OCI policies to require tags
  • Set up alerts for non-compliant resources
  • Create automated remediation for missing tags

Was this documentation helpful?

Have suggestions for improving this documentation? Contact us.

What to do next

Pick the path that fits where you are right now.

Trust & run-safety metadata

Key execution details for CloudCostChefs CSV Tag Chef for Azure & OCI so users know what they are downloading or running before they act.

Need verification guidance? See Security & Trust and Responsible Disclosure.

May change resourcesDirect downloadExplicit + inferred metadata

Maintainer

CloudCostChefs

Last Updated

June 4, 2025

Last Tested

February 23, 2026

Minimum Access

Tagging permissions on target Azure resource groups / OCI compartments

Execution Type

Python script suite (CSV-driven tag updates)

Version

2025-06-04

SHA256 Checksum

70c31ff01c85182451aaed25a0700cae4a9dc83b70f4f0a4ab779a06069c1fa0

Verification Notes

SHA256 recorded and ZIP integrity verified on February 23, 2026. This tool writes tags in bulk. Dry-run with a small CSV and verify target scopes before full execution.

Safe Usage Checklist

  • Back up the input CSV and keep a record of prior tag values if rollback is needed.
  • Start with a small sample set before running across all subscriptions/compartments.
  • Run in a non-production subscription/account/tenancy first and capture sample output before broader rollout.
  • Use least-privilege access. Current best hint from docs: Tagging permissions on target Azure resource groups / OCI compartments.

Quick start (fast path)

Minimal steps to safely get value from this tool without reading the entire page first.

Estimated time: 15 minutes setup + 5 minutes per runDifficulty: BeginnerAccess: Write-capable
  1. 1. Confirm scope and permissions

    Use least privilege and test in a non-production scope first. Minimum access hint: Tagging permissions on target Azure resource groups / OCI compartments.

  2. 2. Get the tool package / source

    Download Tool Files and review the files before running.

    Download
  3. 3. Check prerequisites

    • ✅ Python 3.7+
    • ✅ `pandas`, `azure-identity`, `azure-mgmt-resource`, and `oci` packages installed
    • ✅ `az login` or managed identity for Azure authentication
  4. 4. Run safely and review output

    SHA256 recorded and ZIP integrity verified on February 23, 2026. This tool writes tags in bulk. Dry-run with a small CSV and verify target scopes before full execution. Start with a small sample scope, then expand once results look correct.