1

To deploy my infrastructure I need to deploy a VM with a custom script extension. The only purpose of the VM, is to execute the script. After the execution of the script the VM should be deleted automatically.

How can this be done?

Additional information:

  • This is an azure resource manager deployment
  • the deletion should work in the azure marketplace environment as well.
2

1 Answer 1

1

this probably means you are doing something wrong, you can use Azure Container Instance to run the script and shutdown. it should work with marketplace as well (as far as I know you can have custom container in marketplace offerings).

Marketplace only allows you to use arm templates to deploy stuff, so you cannot really do what you are asking with an arm template. well, you might be able to hack something like that with nested deployments and complete mode, but I doubt that will pass moderation in marketplace.

technically, you can make vm delete itself as a part of the script. again, not something I would advise.

4
  • Thanks for interesting answer. The MS support said, the only way to use scripts in a marketplace deployment is by using a vm. Your arguments make totally sense to me. But how should complex infrastructures, with table storarge, etc. be deployed without a PowerShell script? Mar 22, 2019 at 8:27
  • there is no easy answer for that. you create azure resources, application code can create tables. but you'd need to define etc. many things can be done with arm templates (and many cannot).
    – 4c74356b41
    Mar 22, 2019 at 8:29
  • Go ACI looks like a good Solution for my Issue. But I got the same Question for that. Is it possible to delete the Azure Container Instance after the usage? Just to clean the resource group up. Mar 22, 2019 at 9:09
  • 1
    no, you cannot delete anything with arm templates really. you can make aci delete itself as a part of the script, but you dont have to, you configure container to not restart, so when it finishes the script it doesnt cost money
    – 4c74356b41
    Mar 22, 2019 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.