Currently available in public preview, Pulumi's Automation API enables you to provision your infrastructure programmatically using the Pulumi engine. Today, we are excited to announce C# support for Automation API, enabling .NET developers to automate infrastructure deployments, create complex orchestration workflows, build custom ops tooling, and build cloud frameworks. Read more about the Automation API [here](/blog/automation-api/).
The `Pulumi.Automation` [NuGet package](https://www.nuget.org/packages/Pulumi.Automation) exposes a `LocalWorkspace` for creating and managing Pulumi [Stacks](/docs/concepts/stack/), and a `WorkspaceStack` that is a programmatic representation of a Stack for updating, refreshing, previewing, and destroying cloud resources. The Automation API makes it trivial to run Pulumi programs inline:
You can use your existing Pulumi projects and invoke them from the Automation API:
```csharp
var stackArgs = new LocalProgramArgs("stackName", "C:\path\to\pulumi\project\dir");
using var stack = await LocalWorkspace.CreateOrSelectStackAsync(stackArgs);
await stack.UpAsync();
```
Since the Automation API can be invoked and debugged like any other code, it enables you to put together complex deployment workflows such as a blue-green deployment model:
```csharp
using var workspace = await LocalWorkspace.CreateAsync(new LocalWorkspaceOptions
{
Program = PulumiFn.Create<ApplicationStack>(), // use your existing Pulumi.Stack implementation
ProjectSettings = new ProjectSettings("projectName", ProjectRuntimeName.Dotnet),
});
// your "blue" production code is already running
var green = await WorkspaceStack.SelectAsync("green", workspace);
await green.UpAsync();
// do your cutover to "green" logic
// and then teardown "blue"
var blue = await WorkspaceStack.SelectAsync("blue", workspace);
await blue.DestroyAsync();
```
See full Automation API examples in [C#](https://github.com/pulumi/automation-api-examples/tree/main/dotnet). Let us know if you're using Automation API on [Twitter](https://twitter.com/PulumiCorp) or in our [Community Slack](https://slack.pulumi.com/).