Is there a way in Azure to create a new virtual machine with preselected files that will always be there when establishing the new machine, as well as run them?

I have a shell script that I have to run on new Ubuntu machines that I deploy and I was wondering if there's a way to make Azure already install Ubuntu with those files and maybe even run them.