Seamlessly Adding Tags to Azure Function Apps via Visual Studio: A Guide for Enhanced Resource Management

  • Luis Rigueira
  • Feb 19, 2024
  • 6 min read

Have you ever wondered how to add tags to your Function App through Visual Studio?

Using the Azure Portal

Let’s break it down, but first, here’s a quick overview of how you would do it in the Azure Portal:

  • On your Function App overview page, under the Essentials information on the left, you’ll find Tags with an Edit button next to it.
Tags
  • Clicking on it allows you to add new tags to your function app. These tags essentially function as meta tags, consisting of key-value pairs, such as Name and Value.
Edit Tags

But why do I need tags? You might be wondering.

What tags can offer?

Overall, tags offer a flexible and customizable way to manage and govern resources in Azure, enabling better organization, cost management, monitoring, and governance across your environment.

  • Organization and Categorization: Tags help you categorize and organize resources by criteria such as department, project, environment (for example, production or development), or cost center. As a result, you can locate and manage resources more easily, even in large deployments with many components.
  • Cost Management: Tags support cost allocation and tracking across subscriptions and resource groups. By assigning tags, you can clearly associate costs with specific projects, teams, or departments. This visibility improves budgeting, forecasting, and cost optimization.
  • Monitoring and Reporting: Tags add valuable metadata for monitoring and reporting scenarios. You can filter and aggregate data using tags, which helps you analyze resource usage, performance, and operational trends across different categories.
  • Access Control and Governance: Tags also support access control and governance strategies. By tagging resources based on sensitivity, compliance, or ownership, you can enforce policies, permissions, and standards more effectively.

📝 One-Minute Brief

Managing Azure resources at scale requires consistent tagging. This article shows how to add tags to Azure Function Apps directly from Visual Studio, streamlining deployments and improving governance without manual portal work. By embedding tags at development time, teams can enhance cost management, ownership tracking, and resource organization from day one.

Using the Visual Studio

Now that we have already described the importance of tags and how you can add them from the Azure Portal, let’s dive into it with Visual Studio:

  • After you’ve published your Azure Function, or if you’re working with an existing published one, head over to the Solution Explorer and right-click on your solution.
New Project
  • From there, go to Add > New Project. Now, search for the Azure Resource Group and double-click it.
Azure Resource Group
  • You’ll be prompted to name your project. You can leave the location as is since it’s the project you’re currently working on. Click on Create once you’re done.
Framework
  • Now, in the Solution Explorer, you’ll spot a new project. Inside, you’ll find two .json files:
    • azuredeploy.json
    • azuredeploy.parameters.json
  • The file we’re interested in is azuredeploy.json. Double-click on it and replace its content with the provided JSON. Don’t forget to customize it with the tags you need and also your Function App Name. For now, let’s use these tags for our proof of concept:
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "functionAppName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Azure Function App"
      },
      "defaultValue": "YOUR-FUNCTION-APP-NAME"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Web/sites",
      "apiVersion": "2020-12-01",
      "name": "[parameters('functionAppName')]",
      "location": "West Europe",
      "properties": {
        "siteConfig": {
          // Define site configuration properties here
        }
      },
      "tags": {
        "Environment": "POC",
        "Project": "PdfMerger",
        "Company": "DevScope",
        "Year": "2024"
      }
    }
  ],
  "outputs": {}
}
  • Back in the Solution Explorer, right-click on the project you’ve just created and select Deploy > New.
Deploy
  • You’ll then need to choose your subscription and resource group. Finally, hit Deploy.
Deploy

Once the deployment finishes smoothly without any errors, it’s time to inspect your Function App. You’ll notice that all your tags are now displayed on the Function App overview page.

Function App in the portal

Adding tags to your function app in Visual Studio provides a streamlined way to organize, manage, and govern your resources in Azure by categorizing them by criteria such as environment, project, company, etc.

Importance of using tags

Tags simplify navigation and resource management, especially in complex deployments. Moreover, they play a key role in cost allocation, monitoring, reporting, and access control. As a result, tags provide valuable insights and strengthen governance across the environment.

Both Visual Studio and the Azure Portal let you manage tags for resources like Function Apps. However, when working with simple solutions that require multiple environments, Visual Studio offers several clear advantages:

  • Automation and Consistency: Visual Studio enables you to automate the deployment of resources and their tags using Infrastructure as Code (IaC) principles. This ensures consistency across deployments and reduces the chance of human error compared to manually adding tags in the Azure Portal.
  • Version Control: When managing your Azure resources through Visual Studio, you can maintain version control over your infrastructure code. This means you can track changes to your tags along with other resource configurations, making it easier to revert to previous versions if needed.
  • Integration with Development Workflow: For teams that primarily work within Visual Studio for development tasks, integrating tag management into the development workflow streamlines processes. Developers can manage both code and resource configurations in a unified environment, enhancing collaboration and efficiency.
  • Scalability: Visual Studio is well-suited for managing tags across multiple resources or environments. With the ability to define and deploy resource templates containing tags programmatically, scaling tag management becomes more manageable, especially in large-scale deployments.
  • Consolidated Management: Using Visual Studio for tag management allows you to centralize the configuration of tags alongside other resource settings. This consolidated approach simplifies overall resource management, providing a single interface for configuring and deploying resources and their associated tags.

Choosing between Visual Studio and the Azure Portal ultimately depends on your specific requirements, preferences, and existing workflows. Although Visual Studio provides advantages for tag management, the Azure Portal offers a user‑friendly interface. Therefore, it often fits better for simple or ad‑hoc tag assignments.

For this reason, organizations should evaluate their needs and capabilities to determine the most suitable approach for managing tags in their Azure environment.

That said, the most effective solution is to automate tagging through CI/CD pipelines.

Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for Sandro’s son!

Buy me a Lego
Author: Luis Rigueira

Luis Rigueira is a Enterprise Integration Consultant at DevScope

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top