Azure Resource Manager (ARM) templates is a service provided by Microsoft Azure that allows you to provision, manage, and delete Azure resources using declarative syntax. These templates can be used to deploy and manage resources such as virtual machines, storage accounts, and virtual networks in a consistent and reliable manner. To deploy the template, you can use the Azure Portal, Azure CLI, or Azure PowerShell.
In this article, we’ll use the Azure Portal to create, deploy and export resources using ARM templates:
Deploying ARM templates
The first thing you need to do is to search for the service “Deploy a custom template”. After selecting the service, you’ll see the options:
Build your own template in the editor
Start with a quickstart template or template spec
2. Begin with a quickstart template, then type “docker-simple-on-ubuntu” and press Next. Add the required parameters, such as resource group, username, DNS, and password, then click Create.
3. You can also modify the template based on your requirements before creating the resources.
4. Once the deployment is successful, you can go to the selected resource group, and you’ll see the created resources from the ARM template.
5. When the Azure resources are no longer needed, you can clean up the resources by deleting the resource group.
If you want to save the current state of the resource group, scroll down to the Automation section and click Export template, then click the download button.
Before re-using the template for production deployments, you may want to revise it since the template we used is a quickstart template.
Creating ARM templates
1. Now that you’ve learned how to deploy using a quickstart template, let’s now try creating an ARM template from scratch. Go back to the “Deploy a custom template” page and click Build your own template in the editor.
2. Once you are redirected to the editor page, you’ll see that there are no parameters, variables, and resources. In this section, we’ll create and deploy an Azure web app template.
3. Click Add resource, select Web app, fill up the remaining fields and press OK.
4. In the editor page, you’ll notice that a JSON has been created. Feel free to change any of the parameters based on your requirements.
5. If you want to save the template you’ve created, just click the Download button. Now let’s save the template, and you’ll be redirected to the configuration of the resource. Just fill up the required fields and click Create.
6. After the deployment is completed, you can go to the resource group and select the web app you’ve created. To confirm if the web app is running, you can access the URL generated by the App Service. The format is: https://<web-app-name>.azurewebsites.net/
7. That’s how simple it is to create and deploy a custom ARM template for your own project. Again, if you no longer need the resource, don’t forget to delete the resource group to avoid unexpected billing in your account.