Azure-docs: New-AzTag cmdlet does not accept -ResourceId parameter

Created on 31 Mar 2020  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

I am getting the following error when running the Powershell cmdlets on this dos:

New-AzTag : A parameter cannot be found that matches parameter name 'ResourceId'.
At line:1 char:11

  • New-AzTag -ResourceId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ...
  • ~~~

    • CategoryInfo : InvalidArgument: (:) [New-AzTag], ParameterBindingException

    • FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.Tags.Tag.NewAzureTagCommand

Re-installed the right version of the module (Install-Module -Name Az -RequiredVersion 3.6.1)
and ran:
New-AzTag -ResourceId /subscriptions/[subscriptionId]/resourceGroups/[RGName] -tag $tags

Was able to work around this by using the Azure Portal and creating the tags on PowerShell, can you please look into this?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri3 azure-resource-managesvc cxp managemensubsvc product-question triaged

All 6 comments

@JoseMSoares-MSFT Thank you for the question! In order to best address your question, could you provide us with the URL of the MS Doc that you were following, if any?

@JoseMSoares-MSFT Thank you for the response!

I just tried the New-AzTag cmdlet and was able to successfully execute it.

Can you please check the version of Az.Resources module on your machine?

This is what I tried:

PS C:> Install-Module Az.Resources

PS C:> Get-Module -ListAvailable Az.Resources

ModuleType  Version    Name          ExportedCommands 
----------- --------   -----         -----------------
Script       1.13.0    Az.Resources  {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, New-AzRoleAssignment...}

And then:

$tags = @{"Dept"="Azure"; "Status"="Normal"}
$resource = Get-AzResource -Name myWebApp -ResourceGroup myRG
New-AzTag -ResourceId $resource.id -Tag $tags

worked fine, resulting in:

Id         : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myRG/providers/Microsoft.Web/sites/myWebApp/providers/Microsoft.Resources/tags/default
Name       : default
Type       : Microsoft.Resources/tags
Properties : 
             Name    Value   
             ======  ========
             Status  Normal

Also, I'd recommend using the Azure Cloud Shell for any ad-hoc command executions as it offers a browser-accessible, pre-configured shell experience for managing Azure resources without the overhead of installing, versioning, and maintaining modules yourself. Do check it out!

Let me know if you still see issues.

Awesome thanks Bhargavi, this fixes my issue :)

@JoseMSoares-MSFT Sure, thanks. Glad I could help! :)

@JoseMSoares-MSFT and @BhargaviAnnadevara-MSFT - thanks for this information. I am going to add a note to the article about required module version that is needed.

Was this page helpful?
0 / 5 - 0 ratings