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

Get-AzureRmResource requires "ResourceName" as mandatory parameter. #1259

Closed
iamshital opened this issue Nov 9, 2015 · 9 comments

Comments

Projects
None yet
9 participants
@iamshital
Copy link

commented Nov 9, 2015

I was using following commands as part of my automation. They worked fine until v.0.9.9

$RGIPdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -Verbose -ExpandProperties -IsCollection
$RGVMs = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -Verbose -ExpandProperties -IsCollection
$NICdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/networkInterfaces" -Verbose -ExpandProperties -IsCollection

Each command gave all resources for given resource type.

But now Get-AzureRmResource requires "ResourceName" as mandatory parameter which is very inconvenient. Coz I use, dynamic resource names for automation.
Of course, I can add some lines of code to make it work but this new change is very inconsistent.

If I execute Get-AzureRmResource it lists all the resources. Great.
If I execute Get-AzureRmResource -ResourceType "someType", I get error - "Parameter set cannot be resolved using the specified named parameters."
I would love to see all the resources who are someType regardless of resource group name.
If I execute Get-AzureRmResource -ResourceType someType -ResourceGroupName RGName, It asks, ResourceName.
I would love to see all the resources who are someType in RGName

@TravisEz13

This comment has been minimized.

Copy link
Member

commented Nov 12, 2015

I can also verify this worked fine without resource name in previous build. Please fix this.

@wi5nia

This comment has been minimized.

Copy link

commented Nov 17, 2015

I cal also confirm that this is not working currently

@mithunshanbhag

This comment has been minimized.

Copy link
Contributor

commented Nov 17, 2015

+1.

@vkulks2015

This comment has been minimized.

Copy link

commented Nov 20, 2015

+1

@rcarmo

This comment has been minimized.

Copy link
Member

commented Dec 10, 2015

I just have to +1 this as well. Can't build the automation I need without it (use case is to shutdown tagged VMs, and can't use the VM names to reference them since the tags are dynamic).

@ravbhatnagar

This comment has been minimized.

Copy link
Contributor

commented Dec 11, 2015

We are looking into fixing this issue.

In the meantime, you can use the following cmdlet which we have added to search for resources via query parameters-
Find-AzureRmResource -ResourceType $resourceType -ResourceGroupNameContains $resourceGroupName to get the list of resources.

Another usecase for the Find cmdlet would be if you'd like to find all the resources containing a specific tag. Such functionality, which was earlier supported through Get, has now been moved to this new cmdlet. This was done to simplify the existing Get-AzureRmResource cmdlet which was pretty overloaded.

Please let us know if you have any questions on this.

@rcarmo

This comment has been minimized.

Copy link
Member

commented Dec 11, 2015

@ravbhatnagar

This comment has been minimized.

Copy link
Contributor

commented Dec 11, 2015

For finding all resources with a given tag, you will use the following -
Find-AzureRmResource -TagName $tagName -TagValue $tagValue

Now, if you'd like to find all resources of a specific type which contains the tag, you can do something like below -
Find-AzureRmResource -TagName $tagName -TagValue $tagValue | Where-Object ResourceType -eq "resource-type"

@ravbhatnagar

This comment has been minimized.

Copy link
Contributor

commented Mar 4, 2016

Fixed - 3/3 PS release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.