git-azure
git-azure copied to clipboard
Set-AzureRmResource returns " The pipeline has been stopped." When trying to add tags in hashtable
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
}
}
}
}
}
It seems to have something to do with properties that have "hidden-link" tag in them.
did you ever resolve your issue?