Untitled.cs
# azure
r
Untitled.cs
m
Copy code
appUserIdentity.Id.Apply(x => {
var reg = new Registry(name, new RegistryArgs
    {
      ResourceGroupName = resourceGroup.Name,
      Location = resourceGroup.Location,
      Sku = new SkuArgs { Name = "Basic" },
      Identity = new IdentityPropertiesArgs
      {
        Type = ResourceIdentityType.UserAssigned,
        UserAssignedIdentities = new InputMap<UserIdentityPropertiesArgs> { { x, new UserIdentityPropertiesArgs() } }
      } 
    });
});
btw, how do you make the code output format like that?
r
Hi Adam, thanks! I tried that and got a warning
Copy code
ResourceCreatedInsideApply: Resource Registry created from inside Output. Apply(...) potentially would not show up during pulumi preview phase depending on whether or not the value of the output instance is known
I don't know if it's ok or there is a better way.
About code format: You should click on the
+
button and select text snippet for code output. But you can use the shortcut.
m
Sorry, I didn't pay attention to what you were actually doing there. the returned object of the apply as you wrote it is the object x which is an output<string> because you are returning the same object you called without running any function on it. if you want it to be a string.
Untitled.ts
You can also use lifting with some objects which is cleaner. ``````
r
Example 1, userId will be an
Output<string>
which will lead to the same error. Example 2: I didn't get the line 9. Did you create a new object appUserIdentity? But any way, I change the code to use the first approach, I ignored the warning message and applied some changes in the code because I was returning a
Registry
object, now, I'm returning
Output<Registry>
It's not a production code, I'm playing with Pulumi just for fun
😄
m
Does this work better in example 1? pulumi.interpolate`${id}` for example 2 see https://www.pulumi.com/docs/iac/concepts/inputs-outputs/apply/#accessing-nested-output-values read the section about lifting.
r
Hi Adam! I guess I've found a better way to solve the issue. Pay attention to lines 3 and 12. The InputMapT should receive a dictionary, I tested and it worked. I got inspiration from this issue on GitHub https://github.com/pulumi/pulumi-dotnet/issues/18 Thanks for sharing your knowledge and time 😄. I appreciated that