After creating an SQL Server database I want to ma...
# getting-started
s
After creating an SQL Server database I want to make the connection string and add it to a key vault.
Copy code
// 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
Copy code
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
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
@stocky-butcher-62635 this blog post may also help understanding `apply()`: https://www.leebriggs.co.uk/blog/2021/05/09/pulumi-apply.html