I added this to the `yml` file for the environmen...
# getting-started
I added this to the
file for the environment
Copy code
RwbPulumiProject:ApplicationName: rwb
(Apparently each setting key must be of the form
The documentation page https://www.pulumi.com/docs/intro/concepts/config/ implies that the first bit is not required but apparently this is untrue.) Then I try to use it
Copy code
Config config = new Pulumi.Config();
        string applicationName = config.Require("RwbPulumiProject:ApplicationName");
(Is is possible to rename the class from
? My* really makes my skin crawl.) But then
Copy code
C:\Work\Azure\RwbPulumiProject>pulumi up
Previewing update (dev)

View Live: <https://app.pulumi.com/jayallcock/RwbPulumiProject/dev/previews/a321fb21-a32a-4b5d-bd30-61c0e6e68c94>

     Type                 Name                  Plan       Info
 +   pulumi:pulumi:Stack  RwbPulumiProject-dev  create     1 error

  pulumi:pulumi:Stack (RwbPulumiProject-dev):
    error: Running program 'C:\Work\Azure\RwbPulumiProject\bin\Debug\netcoreapp3.1\RwbPulumiProject.dll' failed with an unhandled exception:
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
       at object RuntimeTypeHandle.CreateInstance(RuntimeType type, bool publicOnly, bool wrapExceptions, ref bool canBeCached, ref RuntimeMethodHandleInternal ctor, ref bool hasNoDefaultCtor)
       at object RuntimeType.CreateInstanceDefaultCtorSlow(bool publicOnly, bool wrapExceptions, bool fillCache)
       at object RuntimeType.CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, bool fillCache, bool wrapExceptions)
       at T Activator.CreateInstance<T>()
       at Task<int> Pulumi.Deployment+Runner.Pulumi.IRunner.RunAsync<TStack>(IServiceProvider serviceProvider)+() => { }
       at Task<int> Pulumi.Deployment+Runner.RunAsync<TStack>(Func<TStack> stackFactory) ---> Pulumi.Config+ConfigMissingException: Missing Required configuration variable 'RwbPulumiProject:RwbPulumiProject:ApplicationName'
        please set a value using the command `pulumi config set RwbPulumiProject:RwbPulumiProject:ApplicationName <value>`
       at string Pulumi.Config.RequireImpl(string key, string use, string insteadOf)
       at string Pulumi.Config.Require(string key)
       at new MyStack() in C:/Work/Azure/RwbPulumiProject/MyStack.cs:line 17
       --- End of inner exception stack trace ---

@stocky-butcher-62635 the error is in the output, your config is reading:
Copy code
string applicationName = config.Require("RwbPulumiProject:ApplicationName");
which means it needs to be set as:
Copy code
pulumi config set RwbPulumiProject:RwbPulumiProject:ApplicationName
If you change your code to:
Copy code
string applicationName = config.Require("ApplicationName");
it should work
Is is possible to rename the class from MyStack? My* really makes my skin crawl.
Yes, of course it's possible. You'd just need to modify the async call
There's also an
Copy code
azure-native:location: uksouth
but that appears to be impossible to read either with or without the prefix
It's better to set the config values with the
pulumi config set
terminal command versus writing them in the YAML file directly. it's of the form
pulumi config set <key> <value>
. So, for your example, you would run
pulumi config set azure-native:location uksouth
(as an example, here's how someone set up an Azure Native C# Pulumi program)
but I can
but I can't read that value because it's not in the namespace of the project?
You can set it in the YAML file, but the command line call ensures that it's formatted as expected, which is why I recommend it. In terms of not being able to read the value, how are you calling it?
@stocky-butcher-62635 you can read the provider config with this:
Copy code
string awsNative = config.Require("aws-native");