Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

New-AzureTag

New-AzureTag

microsoft.azure.commands.tags.dll

Synopsis

Creates a predefined Azure tag or adds values to an existing tag

Syntax

New-AzureTag [-Name] [-Value] [<CommonParameters>]

Detailed Description

The New-AzureTag cmdlet creates a predefined Azure tag with an optional predefined value. You can also use it to add additional values to existing predefined tags. To create a new predefined tag, enter a unique tag name. To add a value to an existing predefined tag, specify the name of the existing tag and the new value. This cmdlet returns an object that represents the new or changed tag with its values and the number of resources to which it has been applied. New-AzureTag is part of a set of cmdlets (New/Get/Remove) that let you manage predefined Azure tags.An Azure "tag" is a name-value pair that you can use to categorize your Azure resources and resource groups, such as by department or cost center, or to track notes or comments about the resources and groups. You can define and apply tags in a single step, but predefined tags let you establish standard, consistent, predictable names and values for the tags in your subscription. If the subscription includes any predefined tags, you cannot apply undefined tags or values to any resource or resource group in the subscription.To apply a predefined tag to a resource or resource group. use the Tag parameters of the New and Set cmdlets in the AzureResourceManager module. To search for resources or resource groups with a specified tag name or name and value, use the Tag parameters of the Get-AzureResource and Get-AzureResourceGroup cmdlets.Every tag has a name. The values are optional. A predefined Azure tag can have multiple values, but when you apply the tag to a resource or resource group, you apply the tag name and only one of its values. For example, you can create a predefined Department tag with a value for each department, such as Finance, Human Resources, and IT. When you apply the Department tag to a resource, you apply only one predefined value, such as Finance.

Parameters

-Name <String>

Specifies the tag name. To create a new predefined tag, enter a unique name. To add a new value to an existing tag, enter the name of the existing tag.If an existing predefined tag has the specified name, New-AzureTag adds the specified value, if any, to the tag with that name, instead of creating a new tag.

Aliases

None

Required?

true

Position

0

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

-Value <String>

Specifies a tag value. Predefined tags can have multiple value, but you can enter only one value in each command. This parameter is optional, because tags can have names and no values.

Aliases

None

Required?

false

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName)

Accept wildcard characters?

false

Input Type

None

Return Type

Microsoft.Azure.Commands.Tags.Model.PSTag

Notes

Examples

-------------------------- Example 1: Create a predefined tag --------------------------

This command creates a predefined tag named "FY2015". This tag has no values. You can apply a tag with no values to a resource or resource group, or use New-AzureTag to add values to the tag. You can also specify a value when you apply the tag to the resource or resource group.

PS C:\>New-AzureTag -Name FY2015
Name:   Department

Count:  0

Values: 

        Name        Count

        =========   =====

        Finance     0

-------------------------- Example 2: Create a predefined tag with a value --------------------------

This command creates a Department predefined tag with a value of Finance.

PS C:\>New-AzureTag -Name Department -Value Finance
Name:   Department

Count:  0

Values: 

        Name        Count

        =========   =====

        Finance     0

-------------------------- Example 3: Add a value to a predefined tag --------------------------

These commands creates a Department predefined tag with two values. When the tag name exists, New-AzureTag adds the value to the existing tag, instead of creating a new one.

PS C:\>New-AzureTag -Name Department -Value Finance
Name:   Department

Count:  0
Values: 
        Name        Count
        =========   =====
        Finance     0


PS C:\>New-AzureTag -Name Department -Value IT

Name:   Department
Count:  0
Values: 
        Name        Count
        =========   =====
        Finance     0
        IT          0

-------------------------- Example 4: Use a predefined tag --------------------------

The commands in this example create and use a predefined tag.

PS C:\>New-AzureTag -Name CostCenter -Value 0001


Name:   CostCenter
Count:  0
Values: 
        Name        Count
        =========   =====
        0001        0


PS C:\>Set-AzureResourceGroup -Name EngineerBlog -Tag @{Name="CostCenter";Value="0001"}


Name:      EngineerBlog
Location:  East US
Resources: 
            
    Name             Type                     Location
    ===============  =======================  ========
    EngineerBlog     Microsoft.Web/sites      West US
    EngSvr01         Microsoft.Sql/servers    West US
    EngDB02          Microsoft.Sql/databases  West US
Tags: 
    Name         Value
    ==========   =====
    CostCenter   0001


PS C:\>Get-AzureTag -Name CostCenter


Name:   CostCenter
Count:  1
Values: 
        Name        Count
        =========   =====
        0001        1

PS C:\>Get-AzureResourceGroup -Tag @{Name="CostCenter"}

Name:      EngineerBlog
Location:  East US
Resources: 
     Name             Type                     Location
    ===============  =======================  ========
    EngineerBlog     Microsoft.Web/sites      West US

    EngSvr01         Microsoft.Sql/servers    West US
    EngDB02          Microsoft.Sql/databases  West US
Tags: 
    Name         Value
    ==========   =====
    CostCenter   0001

Online Version
Get-AzureTag
Remove-AzureTag