Firstly, apologies for the delay in responding here.
There are multiple ways you can achieve your ask. Below are few suggestions, please check and see what works for your better.
- You can use Custom Script Extension for your requirement. The Custom Script Extension is primarily used for post deployment configuration and software installation. Please refer this document for more details on this. Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux
Here is a walkthrough tutorial on how to run tasks while a VM is created, Custom Script for Linux extension.
- Action Run commands for Linux. Refer this document for details on this.
- Azure automation to run scripts inside a Linux VM. Here is an example on how to use Azure Automation to run scripts inside Linux VM.
- You can also consider using deployment scripts in ARM templates. Please refer to this document.
Hope this helps.
Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.
Disclaimer: This response contains a reference to a third party World Wide Web site.
Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.