pulumi/sdk/dotnet
Justin Van Patten 74580168c2
Fix looking up empty version in ResourcePackages.TryGetResourceType (#6084)
When a resource reference is deserialized, it may not have a version in which case `version` will be an empty string. This change fixes `TryGetResourceType` to work correctly when an empty version is passed.
2021-01-12 08:53:52 -08:00
..
cmd/pulumi-language-dotnet Read .NET plugin name from version.txt (#5629) 2020-10-28 15:53:29 +01:00
Pulumi Fix looking up empty version in ResourcePackages.TryGetResourceType (#6084) 2021-01-12 08:53:52 -08:00
Pulumi.FSharp Extensions to support input collection initializers with union types (#5938) 2020-12-14 20:33:53 +01:00
Pulumi.Tests Fix looking up empty version in ResourcePackages.TryGetResourceType (#6084) 2021-01-12 08:53:52 -08:00
.editorconfig Add **preview** .NET Core support for pulumi. (#3399) 2019-10-25 16:59:50 -07:00
.gitignore Add **preview** .NET Core support for pulumi. (#3399) 2019-10-25 16:59:50 -07:00
dotnet.sln Remove .NET examples (#3419) 2019-10-30 08:16:06 +01:00
Makefile fixing the install of the DotNet SDK 2021-01-06 20:13:34 +00:00
pulumi_logo_64x64.png Add **preview** .NET Core support for pulumi. (#3399) 2019-10-25 16:59:50 -07:00
README.md Remove preview language from dotnet readme. 2020-04-24 13:54:41 -07:00

.NET Language Provider

A .NET language provider for Pulumi.

Building and Running

To build, you'll want to install the .NET Core 3.0 SDK or greater, and ensure dotnet is on your path. Once that it does, running make in either the root directory or the sdk/dotnet directory will build and install the language plugin.

Once this is done you can write a Pulumi app written on top of .NET. You can find many examples showing how this can be done with C#, F#, or VB. Your application will need to reference the Pulumi NuGet package or the Pulumi.dll built above.

Here's a simple example of a Pulumi app written in C# that creates some simple AWS resources:

// Copyright 2016-2019, Pulumi Corporation

using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws.S3;

class Program
{
    static Task<int> Main()
        => Deployment.RunAsync(() =>
        {
            var config = new Config("hello-dotnet");
            var name = config.Require("name");

            // Create the bucket, and make it public.
            var bucket = new Bucket(name, new BucketArgs { Acl = "public-read" });

            // Add some content.
            var content = new BucketObject($"{name}-content", new BucketObjectArgs
            {
                Acl = "public-read",
                Bucket = bucket.Id,
                ContentType = "text/plain; charset=utf8",
                Key = "hello.txt",
                Source = new StringAsset("Made with ❤, Pulumi, and .NET"),
            });

            // Return some values that will become the Outputs of the stack.
            return new Dictionary<string, object>
            {
                { "hello", "world" },
                { "bucket-id", bucket.Id },
                { "content-id", content.Id },
                { "object-url", Output.Format($"http://{bucket.BucketDomainName}/{content.Key}") },
            };
        });
}

Make a Pulumi.yaml file:

$ cat Pulumi.yaml

name: hello-dotnet
runtime: dotnet

Then, configure it:

$ pulumi stack init hello-dotnet
$ pulumi config set name hello-dotnet
$ pulumi config set aws:region us-west-2

And finally, preview and update as you would any other Pulumi project.