https://pulumi.com logo
#dotnet
Title
# dotnet
h

hallowed-lighter-32564

03/02/2023, 5:20 AM
I've been trying unsuccessfully to use the new .NET resource provider functionality to create a simple .NET provider and resource. Is there an example anywhere I could follow?
e

echoing-dinner-19531

03/02/2023, 10:28 AM
If your stuck on something specific I can probably give some direction as well
h

hallowed-lighter-32564

03/02/2023, 10:24 PM
Say I created a custom provider;
Copy code
public class WibbleProvider : Pulumi.Experimental.Provider.Provider
{
  public override async Task<CheckResponse> Check(CheckRequest request, CancellationToken ct)
  {
    await Task.CompletedTask;

    Console.WriteLine("The wibble provider is checking something...");

    return new CheckResponse();
  }
}
I'm not sure how to create a resource type using this provider.
e

echoing-dinner-19531

03/02/2023, 10:45 PM
You'll want to fill in the GetSchema method and then invoke the code generator on that. GetSchema just returns a JSON string for a Pulumi schema which is documented here: https://www.pulumi.com/docs/guides/pulumi-packages/schema/ You can invoke codegen by either having a file copy of that schema, or building your provider into an .exe (or linux executable) and then running
pulumi package gen-sdk --langauge dotnet --out sdk ./provider_exe_or_schema_json
Schema generation is a bit complicated at the moment, we've got one workstream looking into doing it automatically for Go providers just based on Go types. We might look at doing the same for dotnet, or we might see if we can just make schemas easier to write.
7 Views