https://pulumi.com logo
#dotnet
Title
# dotnet
m

mysterious-australia-14256

04/06/2020, 8:54 PM
How can I extract an Azure resources ID as a string? I have created a new AppService which has an ID property in the form of Output<string>. I want to use the ID of this AppService object to call the Pulumi.Azure.Monitoring.Invokes.GetDiagnosticCategories method in order to get a list of the supported monitoring categories so I can enable them all. To call GetDiagnosticCategories I need to pass in a GetDiagnosticCategoriesArgs which has a single property of ResourceId as a string (not Output<string> so if I try and pass in myAppService.ID it errors. Is there a way to achieve this?
t

tall-librarian-49374

04/07/2020, 5:57 AM
You need to use `.Apply()`:
Copy code
app.Id.Appply(id => 
{
  var b = GetDiagnosticCategories(...id...));
  ...
}
m

mysterious-australia-14256

04/07/2020, 8:21 AM
Thanks @tall-librarian-49374. Am I right in thinking that the Apply will return another Output<> containing the logs types? I can see that would let me iterate through them but s there a way to print them out to the console just so I can see what options are available?
t

tall-librarian-49374

04/07/2020, 11:08 AM
Yes, it’s outputs all the way. Once you get an output, you have to do everything with
Apply
So, your printing has to be inside
Apply
too. Alternatively, if you have e.g.
Output<string>
, you can also save it to stack outputs and they will be printed after
pulumi up
is done.
m

mysterious-australia-14256

04/07/2020, 1:21 PM
Makes sense, thanks!