How can I extract an Azure resources ID as a strin...
# dotnet
m
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
You need to use `.Apply()`:
Copy code
app.Id.Appply(id => 
{
  var b = GetDiagnosticCategories(...id...));
  ...
}
m
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
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
Makes sense, thanks!