sparse-intern-71089
10/26/2021, 10:14 AMbrave-planet-10645
10/26/2021, 3:02 PMMain()
method should look like this:
static Task Main()
{
var serviceCollection = new ServiceCollection();
var serviceProvider = serviceCollection
.AddSingleton<MyStack>()
.BuildServiceProvider();
return Deployment.RunAsync<MyStack>(serviceProvider);
}
So you're not registering Stack
in thesingleton, just MyStack
bored-oyster-3147
10/26/2021, 3:15 PMDeployment
is trying to resolve for MyStack
which you provided via RunAsync<MyStack>
but you only have it registered as Stack
bored-oyster-3147
10/26/2021, 3:19 PMIServiceProvider
than you will want to make sure that it is registered as Transient
instead of Singleton
. Pulumi relies on the stack actually being instantiated within the deployment so if you run multiple deployments against the same service provider instance than only the first deployment will actually work when it is registered as singleton.
But if you're actually just running it as a console application in practice, like your example, than singleton will suffice.bumpy-grass-54508
10/26/2021, 4:03 PMTask<int>
or you can get into some trouble if your stack throws any exceptions:
https://github.com/pulumi/pulumi/issues/7050#issuecomment-851580328worried-city-86458
10/26/2021, 7:00 PMblue-pharmacist-31672
10/27/2021, 11:02 AMblue-pharmacist-31672
10/27/2021, 11:02 AM