pulumi-azure
pulumi-azure copied to clipboard
GetFunctionAppHostKeysArgs should take Input<string> instead of string
I'm trying to setup a situation in which I can provision a Function App and pull its hostkey for use in configuring some other resource in the same stack. I think GetFunctionAppHostKeys can be used to achieve this. However, it seems like the GetFunctionAppHostKeysArgs type expects strings for the resource group name and the functionApp name. This means that I cannot pass values of type Output<string> into the args.. This is problematic since a lot of values that I work with in Pulumi are of type Output<T>. Can I get some guidance on this?
The typical way to handle this is to use Apply on the Output<string> and call GetFunctionAppHostKeys inside the Apply, where the value will be a string.
I suppose that's true. Is there a concern it could get unwieldy to be using Output<T>.Apply() all over the place? Anyway, I ended up doing this to set things up:
// get node function info
var hostKeysArgs = Output
.Tuple(functionApp.Name, resourceGroup.Name)
.Apply(t => new GetFunctionAppHostKeysArgs()
{
Name = t.Item1,
ResourceGroupName = t.Item2
});
var hostKeys = hostKeysArgs.Apply(async (x) => await GetFunctionAppHostKeys.InvokeAsync(x));
var defaultFunctionKey = hostKeys.Apply(result => result.DefaultFunctionKey)
For posterity, there's now a cleaner way to do this:
var defaultFunctionKey = GetFunctionAppHostKeys.Invoke(new()
{
Name = functionApp.Name,
ResourceGroupName = resourceGroup.Name,
}).Apply(result => result.DefaultFunctionKey);