DEV Community

Anthony Bartolo for Microsoft Azure

Posted on • Originally published at techcommunity.microsoft.com on

Step-By-Step: Introduction to Azure Command Line Interface (CLI) with Azure Arm Templates

Written By @jaydestro

Working with Azure Resource Manager Templates provides you with a way to codify your infrastructure using JSON! In this tutorial we'll show you how to get started with using different parameters along side with your template.

From the Azure Resource Manager Overview:

Azure Resource Manager is the deployment and management service for Azure. It provides a consistent management layer that enables you to create, update, and delete resources in your Azure subscription. You can use its access control, auditing, and tagging features to secure and organize your resources after deployment.

When you take actions through the portal, PowerShell, Azure CLI, REST APIs, or client SDKs, the Azure Resource Manager API handles your request. Because all requests are handled through the same API, you see consistent results and capabilities in all the different tools. All capabilities that are available in the portal are also available through PowerShell, Azure CLI, REST APIs, and client SDKs. Functionality initially released through APIs will be represented in the portal within 180 days of initial release.

The following image shows how all the tools interact with the Azure Resource Manager API. The API passes requests to the Resource Manager service, which authenticates and authorizes the requests. Resource Manager then routes the requests to the appropriate service.

With Resource Manager, you can create a template (in JSON format) that defines the infrastructure and configuration of your Azure solution. By using a template, you can repeatedly deploy your solution throughout its lifecycle and have confidence your resources are deployed in a consistent state.

To follow along with this tutorial it's recommended you have:

  • Azure Account
  • Some Bash shell experience
  • General understanding of scripting/programming

Important links you'll need to have:

Parameters section of Azure Resource Manager templates

Deploy resources with Resource Manager templates and Azure CLI

ubuntu-apache-test-page GitHub Repo

To create a resource group:

az group create -l centralus -n \<insert your preferred name here\>

Basic deploy of an ARM template:

az group deployment create --name \<your-deploy-name\> --resource-group \<your resource group name\> --template-file azuredeploy.json

Deploy with specified parameters:

az group deployment create --name \<your deployment group\> --resource-group=\<your resource group name\> --template-file azuredeploy.json --parameter location=eastus testPageTitle="demo jay" testPageBody="\<p\>This is a really cool test page.\</p\>" adminUsername=\<your preferred username\> adminPassword=\<your preferred password\> dnsNameForPublicIP=\<your preferred hostname\>

Have additional questions about this tutorial? Feel free to leave a message below.

Top comments (0)