https://pulumi.com logo
Title
t

tall-needle-56640

02/08/2021, 10:06 PM
Why does
ResourceGroup.Get()
require an ID? I don't see it being used in the spec.
t

tall-librarian-49374

02/08/2021, 10:10 PM
This is not the same thing. You are probably looking for https://www.pulumi.com/docs/reference/pkg/azure-nextgen/resources/getresourcegroup/
t

tall-needle-56640

02/08/2021, 10:12 PM
So what is
ResourceGroup.Get()
?
And why does
new ResourceGroup
and
ResourceGroup.Get()
return the type
ResourceGroup
, but
GetResourceGroup
returns the type
Output<ResourceGroupResult>
? Specifically, why does the latter have to be of type
Output
?
Whether I am creating a resource group or using an existing one, I'd like to be able to use the same code.
Output
screws that all up.
t

tall-needle-56640

02/09/2021, 5:08 PM
Oh, OK. The
name
parameter represents a logical name. I guess I should have thought of that. Can you comment on the differences in return types?
t

tall-librarian-49374

02/09/2021, 5:35 PM
Well, I can comment with “that’s how it works” but I guess that’s not helpful.
GetResourceGroup
is an invoke, so it returns a Task as all other invokes.
t

tall-needle-56640

02/09/2021, 5:48 PM
Ignoring
GetResourceGroup
specifically, it just seems that if I can create a resource group and be returned a non-
Output
type, why would I not be able to get a resource that is returned as a non-
Output
type? Either way, an async operation occurred in the background, right? Having a way to get the same type back makes it easier to code for either situation.
t

tall-librarian-49374

02/09/2021, 5:50 PM
Yes, that’s what
ResourceGroup.Get()
does, right?
By the way,
new ResourceGroup(…)
does not run an async operation with Azure API immediately. It just defines the resource for the engine.
GetResourceGroup
does run against Azure API
t

tall-needle-56640

02/09/2021, 6:48 PM
ResourceGroup.Get()
does do that, but it also expects the user to know the resourceID. This code does exactly what I want. I get the resource I want in the type I want:
var resourceGroup = Output.Create(GetResourceGroup.InvokeAsync(new GetResourceGroupArgs { ResourceGroupName = resourceGroupName }));
var rg = ResourceGroup.Get("resourceGroup", resourceGroup.Apply(r => r.Id));
It's just bizarre that I have to jump through a hoop to get what I want, when it seems like this could be encapsulated with
public static ResourceGroup Get(string name, ResourceGroupArgs args)