This message was deleted.
# dotnet
s
This message was deleted.
n
Any update on this? I'm having issues as well. In particular
config.RequireSecret("<secret>")
returns a type of
Output<string>
which I can't seem to get at.
1
p
No update unfortunately, I still don't know what's wrong with this approach.
b
What secrets provider are you using?
w
If I understand correctly, the issue is that the
databaseServerPassword
can’t be used because it’s an
Output<string>
. This is as per https://www.pulumi.com/docs/intro/concepts/programming-model/#how-secrets-relate-to-outputs So
.Apply
needs to be used and the reference to the secret variable used within the apply. Here is some example code where the secret is used within the
.Apply
to create a resource group:
Copy code
class MyStack : Stack
{
    public MyStack()
    {
        var config = new Pulumi.Config();
        var rgName = config.GetSecret("rgName"); 

        // Create an Azure Resource Group
        var resourceGroupName = rgName.Apply(rgn => {
            var rg = new ResourceGroup(rgn, new ResourceGroupArgs
            {
                Name = rgn,
            });
            return rg.Name;
        });

        var storageAccount = new Account("storage", new AccountArgs
        {
            ResourceGroupName = resourceGroupName,
            AccountReplicationType = "LRS",
            AccountTier = "Standard"
        });

        this.ResourceGroupName = resourceGroupName;
        this.ConnectionString = storageAccount.PrimaryConnectionString;

    }
    [Output] 
    public Output<string> ResourceGroupName { get; set; }
    [Output]
    public Output<string> ConnectionString { get; set; }
}
p
@witty-candle-66007 But we are using apply.
w
Yes. And I saw that but I thought it was because of how you were using the Apply. As it turns out your code is very close to this: https://github.com/pulumi/examples/blob/master/azure-cs-appservice/AppServiceStack.cs Do you have the same problem if you follow the pattern in the referenced example? Or if there are reasons for not following that pattern, can you share your code in full?