https://pulumi.com logo
Title
m

mysterious-australia-14256

09/24/2021, 10:00 AM
Hi, I'm after some advice on how to best handle the following... I am deploying a Virtual Machine to Azure using Pulumi/C#. As part of the deployment I need to run a custom script which I am doing by deploying a VirtualMachineExtension/CustomScriptExtension. In order to do this I need to specify the Uri of the script so as part of the deployment so I plan to first upload the script file to Azure Storage and then delete it after the deployment completes. I planed to use the Azure storage sdk to upload and delete the file to blob storage. How can I ensure that the file is uploaded before the Pulumi VirtualMachineExtension/CustomScriptExtension code runs? Also how can I ensure that the VirtualMachineExtension/CustomScriptExtension deployment has finished running before I delete the file?
t

tall-librarian-49374

09/24/2021, 10:11 AM
Why not use a Blob resource to upload the file and keep it around even after the deployment?
m

mysterious-australia-14256

09/30/2021, 8:52 AM
Hi @tall-librarian-49374, I will be uploading to Blob storage but don't like to keep documents that are no longer required hanging around. Is there anything I can use to make sure the file is uploaded before the CustomScriptExtension deployment runs and that it has completed before I delete the file?
t

tall-librarian-49374

09/30/2021, 9:02 AM
Is there anything I can use to make sure the file is uploaded before the CustomScriptExtension deployment runs
You can add a
dependsOn
from the extension resource to the blob resource I guess
m

mysterious-australia-14256

09/30/2021, 9:43 AM
OK so I'm assuming that would require me to use pulumi code to upload the blob rather than calling the SDK directly, is that correct? In a similar manner is there any way to run SDK code after the CustomScriptExtension deployment finishes (i.e. so I can delete the blob)? e.g. is there a way to run arbitrary code that "DependsOn" a deployemnt? Alternatively is there a way to have arbitrary clean-up code run after all deployments have finished (effectively a finally block)?
t

tall-librarian-49374

09/30/2021, 9:45 AM
m

mysterious-australia-14256

09/30/2021, 9:49 AM
It does indeed. I will try sticking the delete code inside an apply to see if that will do what I need