Created
May 8, 2023 19:55
-
-
Save clientbala/bf801d2590dbb91013a1703d26a61abb to your computer and use it in GitHub Desktop.
CInlineProgramArgs to set the webcontainer path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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