Hello Ashok Kumar Jayabalan,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
I understand that you would like to add a new Azure VM into a custom Linux DNS server using an ARM (Azure Resource Manager) template, and to add an A record to your Linux DNS server.
Solution
To resolve this issue, I would want to believe that your ARM template defines your VM’s infrastructure. Include the necessary resources like the VM, network interfaces, and storage and in your ARM template, add a custom script extension to the VM resource. The extension will run a script on the VM after deployment, it will modify the /etc/hosts
file on the VM to include the desired A record (hostname and IP address). What I can lay my hand on right now as an example for best practices is as follows:
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "customScript",
"apiVersion": "2021-04-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.1",
"settings": {
"script": "echo 'host_ip hostname' >> /etc/hosts"
}
}
}
So, deploy your ARM template using the Azure CLI, PowerShell, or the Azure portal, the custom script extension will execute during VM provisioning and update the /etc/hosts
file. But don't forget to adapt the script and template parameters to match your environment.
References
- Quickstart: Create an Azure DNS Private Resolver - Azure Resource Manager template (ARM template) - Azure DNS Private resolver
- Quickstart: Create an Azure DNS zone and record - Azure CLI - Azure DNS
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam