https://pulumi.com logo
Title
s

stocky-butcher-62635

04/12/2022, 12:33 PM
After creating an SQL Server database I want to make the connection string and add it to a key vault.
// Make the database conneciotn string and store it in the key vault.
            Output<string> cs = administratorLoginPassword.Apply(z => $"Server={sqlServer.FullyQualifiedDomainName}; Database={database.Name}, uid=rwb, pwd={z}");
            KeyVault.Secret s = new KeyVault.Secret($"{PulumiProject}-{ae}-key-vault-secret", new KeyVault.SecretArgs()
            {
                ResourceGroupName = resourceGroup.Name,
                VaultName = v.Name,
                SecretName = "ConnectionString",
                Properties = new KeyVault.Inputs.SecretPropertiesArgs() { Value = cs }
            });
But the value is coming out as junk
Server=Calling [ToString] on an [Output<T>] is not supported.

    To get the value of an Output<T> as an Output<string> consider:
    1. o.Apply(v => $"prefix{v}suffix")
    2. Output.Format($"prefix{hostname}suffix");

    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of Pulumi.; Database=Calling [ToString] on an [Output<T>] is not supported.

    To get the value of an Output<T> as an Output<string> consider:
    1. o.Apply(v => $"prefix{v}suffix")
    2. Output.Format($"prefix{hostname}suffix");

    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of Pulumi., uid=rwb, pwd=Sql-Server-Admin-Password
w

witty-candle-66007

04/12/2022, 12:58 PM
As per the error message, the value is an “Output” and therefore needs to be resolved before using. See: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/ And specifically, the apply section.
b

billowy-army-68599

04/12/2022, 1:58 PM
@stocky-butcher-62635 this blog post may also help understanding `apply()`: https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html