Skip to content

Instantly share code, notes, and snippets.

@clientbala
Created May 8, 2023 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clientbala/bf801d2590dbb91013a1703d26a61abb to your computer and use it in GitHub Desktop.
Save clientbala/bf801d2590dbb91013a1703d26a61abb to your computer and use it in GitHub Desktop.
CInlineProgramArgs to set the webcontainer path
using Microsoft.AspNetCore.Mvc;
using Pulumi.Automation;
using System.Reflection;
using Resources = Pulumi.AzureNative.Resources;
using Storage = Pulumi.AzureNative.Storage;
namespace PulumiOverHttpContainer.Controllers
{
public class CInlineProgramArgs : InlineProgramArgs
{
internal static ProjectSettings Default(string name) =>
new ProjectSettings(name, new ProjectRuntime(ProjectRuntimeName.Dotnet))
{
Main = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.Parent.FullName
};
public CInlineProgramArgs(
IWebHostEnvironment env,
string projectName,
string stackName,
PulumiFn program) : base(projectName, stackName, program)
{
this.WorkDir = env.WebRootPath;
this.ProjectSettings = CInlineProgramArgs.Default(projectName);
}
}
[ApiController]
[Route("[controller]")]
public class CreateStorageController : ControllerBase
{
...
[HttpGet]
public async Task<IActionResult> Get(string stackName, string resourceGroupName, string storageAccountName)
{
var program = PulumiFn.Create(() =>
{
...
// Provision Azure Native resources...
});
var stackArgs = new CInlineProgramArgs(_env, "PulumiOverHttpContainer", stackName, program);
var stack = await LocalWorkspace.CreateOrSelectStackAsync(stackArgs);
....
return new OkObjectResult("Success");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment