https://pulumi.com logo
#dotnet
Title
m

miniature-leather-70472

02/17/2021, 2:46 PM
I've got some C# Pulumi deployment that works great, but at the end of the deployment I need to call an http webhook, passing one of the values created during my deployment. Can I do this in my Pulumi project, maybe using httpclient or similar, or does this need to occur outside of my Pulumi code in another pipeline step or similar? I'm not clear how Pulumi deals with additional C# code that depends on a value generated by the deployment
w

witty-candle-66007

02/17/2021, 3:56 PM
Yes, you can run “other” C# code in your pulumi program. Pulumi will try to run it on all
pulumi preview
or
pulumi up
calls. So you may want to put a conditional around it using
isDryRun()
(https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/runtime/#isDryRun) to avoid the code running during preview.
t

tall-librarian-49374

02/17/2021, 4:18 PM
You should probably do that inside an
Apply
when all dependencies for that call are resolved.
✔️ 1
n

numerous-artist-1705

02/17/2021, 8:28 PM
@miniature-leather-70472 hey Sam (it's Stef 🙂), I've just implemented this to test an Azure Function after creation; Pulumi does not affect the regular C# code, as @tall-librarian-49374 pointed out, you just want to make sure it runs when you expect it to using
Apply
for dependencies. Have at my implementation here: https://github.com/UnoSD/TvShowRss/blob/95d8ad28ce3ff4c7ea339f0231ad3a03a99f0446/Infrastructure/Program.cs#L404
✔️ 1
m

miniature-leather-70472

02/18/2021, 5:19 PM
Thanks, got that working nicely now. Is there a way to get this to run every time? At the moment it only triggers if there is a change to apply.
t

tall-librarian-49374

02/18/2021, 5:24 PM
I would expect it to run every time.
If value is know,
Apply
is invoked
m

miniature-leather-70472

02/22/2021, 3:22 PM
hmm, I'm seeing some inconsistency, sometimes it runs every time, then sometimes it seems to get skipped
t

tall-librarian-49374

02/22/2021, 3:29 PM
Then, I suspect you ignore the result of
Apply
. You should assign it to stack outputs to guarantee the execution.