I'm having a bit of a struggle with the new AzureN...
# dotnet
I'm having a bit of a struggle with the new AzureNative API and am presumably missing something obvious. I have created a new netcoreapp3.1 project and pasted the ServiceBus C# code from the Pulumi docs into the MyStack.cs file. I am presented with 2 errors, on the lines trying to set the Sku Name and Tier
Copy code
Sku = new AzureNative.ServiceBus.Inputs.SBSkuArgs
                Name =  "Standard",
                Tier = "Standard",
The error I get is of the type Cannot implicitly convert type 'string' to 'Pulumi.Input<Pulumi.AzureNative.ServiceBus.SkuName>' Can someone let me know what I am missing? Thanks Alan
It looks like our example is wrong - you should pass an enum value instead of a plain string
Ah thanks @tall-librarian-49374. How does this work with storing values in config files? Do the config class methods (e.g. RequireObject) support deserializing to an Enum or do I have to wrap things in an Enum.Parse?
I am a bit stuck here. Looking at the definition I see
Copy code
public readonly struct SkuName : IEquatable<SkuName>
        public static SkuName Basic { get; }
        public static SkuName Standard { get; }
        public static SkuName Premium { get; }
If I try to use Enum.Parse on this I get back an error saying "Type provided must be an Enum.". Do you know how I can convert the string "Standard" stored in a config file into something that SBSkuArgs will accept as a value for Name or Tier? I was trying
(SkuName)Enum.Parse(typeof(SkuName), "Standard")
This seems to work.. (configTier is a string variable read from the config file)
Tier = (SkuTier)(typeof(SkuTier).GetProperty(configTier )?.GetValue(null))!,
but is is a lot uglier than the AzureNextGen version which was simply
Tier = configTier
That’s an interesting use case that we missed I’m afraid. I’m glad you found a workaround. Could you open an issue in https://github.com/pulumi/pulumi/issues describing this?
🙏 1