During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in
Using Locally with ARM Templates
ARM Templates are JSON files that describe the Azure infrastructure you want to deploy. You can deploy ARM Templates against Locally either by using the locally deploy command (which generates a resource group/deployment name, if unspecified, and deploys into the first subscription alphabetically by default) or by using the same commands you would with the Azure CLI (see below).
Every ARM Template targets a scope - a Resource Group (the default), a Subscription, a Management Group or a Tenant.
Resource Group Deployments
Most templates deploy into a Resource Group. For example, this template creates an Availability Set:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "2024-11-01",
"name": "example-from-armtemplate",
"location": "berlin",
"properties": {
"platformFaultDomainCount": 3,
"platformUpdateDomainCount": 5
},
"sku": {
"name": "Aligned"
}
}
]
}
If Locally isn't already running, we'll need to start it by running:
$
locally build
Then, if the template's saved as template.json, you can deploy it with:
$
locally deploy template.json
If you don't specify a Subscription, the first Subscription alphabetically will be used, and if you don't specify a name for the Resource Group or Deployment then one will be randomly generated as needed. You can specify these values by setting:
-
--subscription {UUID}- the Subscription to deploy into. Defaults to the First Subscription. -
--resource-group {name}- the Resource Group to deploy into, which is created if it doesn't already exist. -
--deployment {name}- the name to record the Deployment under. -
--parameters {file}- a parameters file (.json).
For example, to deploy into a Resource Group named dev in a specific Subscription:
$
locally deploy --subscription 9fae9a7d-5fd4-4b18-8efc-22ac8eb6eaaa --resource-group dev template.json
Subscription Deployments
To deploy at the Subscription scope instead, use the Subscription deployment template $schema. This one creates a Resource Group:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2021-04-01",
"name": "from-subscription-deployment",
"location": "berlin"
}
]
}
Subscription deployments also take a --location flag, which sets where the Deployment's metadata is stored and defaults to berlin:
$
locally deploy --location berlin subscription-template.json
The --subscription, --deployment and --parameters flags work the same way as for Resource Group deployments, but --resource-group doesn't apply at this scope.
Management Group Deployments
To deploy at a Management Group, use the Management Group deployment template $schema. This one adds a Policy Definition to the Management Group, which every Subscription beneath it can then assign:
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Authorization/policyDefinitions",
"apiVersion": "2021-06-01",
"name": "require-environment-tag",
"properties": {
"displayName": "Require an environment tag on Resource Groups",
"policyType": "Custom",
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"field": "tags['environment']",
"exists": "false"
}
]
},
"then": {
"effect": "deny"
}
}
}
}
]
}
Pass the Management Group to deploy into with --management-group:
$
locally deploy --management-group platform management-group-template.json
The --deployment, --location and --parameters flags work the same way as for Subscription deployments.
Heads up
Tenant Deployments
Locally doesn't support Tenant scoped deployments at this time, but we plan to in the future. We're tracking this feature request in this issue on the Locally Issue tracker.
Deploying via the Azure CLI
If you'd rather use the Azure CLI, prefix az deployment group create with locally run to deploy an ARM Template into an existing Resource Group:
$
locally run az deployment group create --resource-group example --template-file template.json
And az deployment mg create deploys into a Management Group:
$
locally run az deployment mg create --management-group-id platform --location berlin --template-file management-group-template.json
Next steps
You can see what you've deployed in the Locally Dashboard, and the Examples include ARM Templates for many common resources. If you'd rather write Bicep, see the Bicep guide.
Each deployment has its own page in the Dashboard, showing each resource as it's provisioned. You can also paste a template into the Dashboard's Deploy ARM template page, which validates it as you type and shows a What-If preview before you deploy. If your template lives in a public repository, a Deploy to Locally button in its README opens it there in one click.
During Public Preview you can use the Team plan for free, and get an early-adopter discount at GA. Sign in