I've got some C# Pulumi deployment that works grea...
# dotnet
m
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
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
You should probably do that inside an
Apply
when all dependencies for that call are resolved.
✔️ 1
n
@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
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
I would expect it to run every time.
If value is know,
Apply
is invoked
m
hmm, I'm seeing some inconsistency, sometimes it runs every time, then sometimes it seems to get skipped
t
Then, I suspect you ignore the result of
Apply
. You should assign it to stack outputs to guarantee the execution.