Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set-AzureRmResource returns " The pipeline has been stopped." When trying to add tags in hashtable #63

Open
Yanivro opened this issue May 17, 2016 · 2 comments

Comments

@Yanivro
Copy link

Yanivro commented May 17, 2016

Trying to handle adding tags while not overwriting the current tags on the resource
by adding them to the $tags hash-table like shown here:

https://azure.microsoft.com/en-us/documentation/articles/resource-group-using-tags/

Same error in both Azure Automation Runbook and my station.

updates all packages and they work fine.

It works on Set-AzureRmResourcegroup but not on Set-AzureRmResource

Error message:

Set-AzureRmResource : The pipeline has been stopped.
At line:1 char:1
+ Set-AzureRmResource -ResourceId $rm.ResourceGroupName -Tag $tags
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmResource], PipelineStoppedException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureResourceCmdlet

Set-AzureRmResource : MissingSubscription : The request did not have a provided subscription. All requests must have an asso
ciated subscription Id.
At line:1 char:1
+ Set-AzureRmResource -ResourceId $rm.ResourceGroupName -Tag $tags
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmResource], ErrorResponseMessageException
    + FullyQualifiedErrorId : MissingSubscription,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureR 
   esourceCmdlet

Code:

$naming = Import-Csv "E:\tags.csv"

foreach ($name in $naming){

$nameContains=$name.nameConvention
$rms=Find-AzureRmResource -ResourceNameContains $nameContains -ExpandProperties


foreach($rm in $rms){

        $id=$rm.ResourceId
        $tags=$rm.tags


                if ($rm.name -Match $name.nameConvention ){
                    $value=$name.tag
                    if($value){

                if($tags){
                    $exist=$false
                    foreach ($tag in $tags){    
                        if ($tag.Values -contains "Customer"){
                            $exist=$true }}
                    if ($exist -eq $false){

foreach($newtag in $tags){

$tags| get-member

}

$newthing=@( @{ Name="Customer"; Value=$value})

                    $tags += @{ Name="Customer"; Value=$value }

                    Set-AzureRmResource -ResourceName $rm.ResourceName -ResourceType $rm.ResourceType -Tag $tags 


                }} else {

                    $value=$name.tag

                    Set-AzureRmResource -ResourceId $id -Tag @( @{ Name="Customer"; Value=$value ; $tags. }) -Force

                }

            }

            }


    }
}
@Yanivro
Copy link
Author

Yanivro commented May 17, 2016

It seems to have something to do with properties that have "hidden-link" tag in them.

@ikiris04
Copy link

ikiris04 commented Aug 7, 2017

did you ever resolve your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants