pulumi-azure-native
pulumi-azure-native copied to clipboard
Not updated example of the C# code for Azure API Management
What happened?
There is documentation about the class that is responsible for Azure API Management. The link: https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/ The C# example has initialization of the Protocols property like that
var api = new AzureNative.ApiManagement.Api("api", new()
{
...
Protocols = new[]
{
"https",
"http",
},
...
});
The problem is that Protocols has type of List<Union<string, Pulumi.AzureNative.ApiManagement.Protocol>>
Also, I can't find any documentation about the usage of the Union type.
Example
No
Output of pulumi about
No
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
Hi @paf-dev, the Union type is defined in the shared dotnet SDK here
The reason the code example doesn't explicitly instantiate it is that Union provides implicit conversions link, so the compiler will automatically convert those Strings into Union<string, Pulumi.AzureNative.ApiManagement.Protocol>s
The reason the code example doesn't explicitly instantiate it is that
Unionprovides implicit conversions link, so the compiler will automatically convert thoseStrings intoUnion<string, Pulumi.AzureNative.ApiManagement.Protocol>s
I also thought about implicit conversion, but dotnet build still says the following
error CS0029: Cannot implicitly convert type 'string[]' to 'Pulumi.InputList<Pulumi.Union<string, Pulumi.AzureNative.ApiManagement.Protocol>>
@paf-dev did you solve this? Getting the same issue. Do you really mean this Protocols = ["https"] or Protocols = new InputList<Union<string, Protocol>>() {"https"}
@TheRubble Here is what I used in my code to make it work
Protocols = new Union<string, Protocol>[]
{
Protocol.Https
},
Probably not the best, but at least it worked and I was not blocked by the service that actually takes my company's money for that
["https"]
["https"] this will work then :-)
Since there seems to be a working solution, I'll close this issue, but please feel free to re-open if necessary.